如何在 Windows 7 任务栏中显示进度(使用 Qt)?

发布于 2024-10-06 02:50:05 字数 210 浏览 1 评论 0 原文

有没有办法用 Qt 访问 windows 7 进度条?我目前正在使用 Qt 4.7.0 和 Qt Creator。

我已经找到了 Q7Goodies 但不幸的是它不是免费的。所以这似乎是可能的 - 我如何手动访问进度条(没有 Visual Studio)?

Is there a way to access the windows 7 progress bar with Qt? I'm currently using Qt 4.7.0 with Qt Creator.

I already found Q7Goodies but unfortunately it is not free. So it seems to be possible - how can I access to the progress bar by hand (without Visual Studio)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

下雨或天晴 2024-10-13 02:50:05

我认为他们使用了Win7 API函数并将它们封装在他们的库中。您可以手动包含这些标头并使用它们。您可以在这里找到帮助主题和演示项目:codeproject.com/KB/vista/SevenGoodiesTaskbarStatus。 aspx

但它只适用于win7。不跨平台。祝你好运

2014 年 3 月 5 日更新

这个问题很久以前就被提出了,从那以后很多事情都发生了变化。对于今天(2014 年初)问自己同样问题的人来说,我个人的答案是 Qt 5 完全支持任务栏进度和不同类型的漂亮附加功能。请参阅 QWinTaskbarProgress2016 年 11 月 28 日更新 )了解详情

I think they used Win7 API functions and encapsulated them in their library. You can include by hand those headers and use them too. Here you can find a help topic and demo project: codeproject.com/KB/vista/SevenGoodiesTaskbarStatus.aspx

But its only for win7. Not crossplatform. Good luck

update mar 05, 2014

This question was asked a long time ago and many things have changed since. For those asking themselves the same question today (beginnings of 2014) then my personal answer is that Qt 5 fully supports progress in taskbar and different kind of beautiful extras. See QWinTaskbarProgress (upd nov 28, 2016) for details

好多鱼好多余 2024-10-13 02:50:05

您可以使用 QWinTaskbarProgress 类。要使用此类,您需要在 .pro 文件中添加 win32:QT += wineextras

以下示例代码展示了如何在 Windows 任务栏中显示 QProgressBar 的值 (受此示例启发):

#ifdef _WIN32    //The _WIN32 macro is automatically generated when compiling for Windows
    #include <QWinTaskbarProgress>
    #include <QWinTaskbarButton>
#endif
QProgressBar *progressBar = new QProgressBar;
progressBar->show();
#ifdef _WIN32
    QWinTaskbarButton *windowsTaskbarButton = new QWinTaskbarButton;    //Create the taskbar button which will show the progress
    windowsTaskbarButton->setWindow(progressBar->windowHandle());    //Associate the taskbar button to the progress bar, assuming that the progress bar is its own window
    QWinTaskbarProgress *windowsTaskbarProgress = windowsTaskbarButton->progress();
    windowsTaskbarProgress->show();
    QObject::connect(loadingWindow, &QProgressBar::valueChanged, [windowsTaskbarProgress](int value){
        windowsTaskbarProgress->setValue(value);   //Change the value of the progress in the taskbar when the value of the progress bar changes
    });
#endif

You can use the QWinTaskbarProgress class. To use this class, you need to add win32:QT += winextras in your .pro file.

Here is an example code showing how to show the value of a QProgressBar in the Windows task bar (inspired from this example):

#ifdef _WIN32    //The _WIN32 macro is automatically generated when compiling for Windows
    #include <QWinTaskbarProgress>
    #include <QWinTaskbarButton>
#endif
QProgressBar *progressBar = new QProgressBar;
progressBar->show();
#ifdef _WIN32
    QWinTaskbarButton *windowsTaskbarButton = new QWinTaskbarButton;    //Create the taskbar button which will show the progress
    windowsTaskbarButton->setWindow(progressBar->windowHandle());    //Associate the taskbar button to the progress bar, assuming that the progress bar is its own window
    QWinTaskbarProgress *windowsTaskbarProgress = windowsTaskbarButton->progress();
    windowsTaskbarProgress->show();
    QObject::connect(loadingWindow, &QProgressBar::valueChanged, [windowsTaskbarProgress](int value){
        windowsTaskbarProgress->setValue(value);   //Change the value of the progress in the taskbar when the value of the progress bar changes
    });
#endif
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文