有没有一种方式可以使用Qt访问Windows 7的进度条?我目前正在使用带有Qt Creator的Qt 4.7.0。
我已经找到了Q7Goodies,但不幸的是它并非免费。因此似乎有可能,那么我该如何手动访问进度条(而不使用Visual Studio)?
有没有一种方式可以使用Qt访问Windows 7的进度条?我目前正在使用带有Qt Creator的Qt 4.7.0。
我已经找到了Q7Goodies,但不幸的是它并非免费。因此似乎有可能,那么我该如何手动访问进度条(而不使用Visual Studio)?
我认为他们使用了Win7 API函数并将它们封装在他们的库中。你可以自己手动包含这些头文件并使用它们。在这里,你可以找到一个帮助主题和演示项目:codeproject.com/KB/vista/SevenGoodiesTaskbarStatus.aspx
但这仅适用于Win7。不是跨平台的。祝好运。
更新于2014年3月5日
这个问题很久以前就被提出了,很多事情都发生了变化。对于那些今天(2014年初)也在思考同样问题的人,我的个人答案是Qt 5完全支持任务栏进度和各种美丽的额外功能。详情请看QWinTaskbarProgress(更新于2016年11月28日)。
QWinTaskbarProgress
类。要使用此类,您需要在.pro文件中添加win32:QT += winextras
。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