Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在Windows7任务栏中显示进度(使用Qt)?_C++_Qt_Windows 7 - Fatal编程技术网

C++ 如何在Windows7任务栏中显示进度(使用Qt)?

C++ 如何在Windows7任务栏中显示进度(使用Qt)?,c++,qt,windows-7,C++,Qt,Windows 7,有没有办法使用Qt访问windows 7进度条?我目前正在QtCreator中使用Qt4.7.0 我已经找到了,但不幸的是它不是免费的。因此,这似乎是可能的-我如何手动访问进度条(没有Visual Studio)?我认为他们使用了Win7 API函数并将其封装在库中。您可以手动包含这些标题并使用它们。您可以在此处找到帮助主题和演示项目: 但它只适用于win7。不是跨平台的。祝你好运 2014年3月5日更新 这个问题很久以前就被问到了,此后许多事情都发生了变化。对于那些今天(2014年初)问自己同

有没有办法使用Qt访问windows 7进度条?我目前正在QtCreator中使用Qt4.7.0


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

我认为他们使用了Win7 API函数并将其封装在库中。您可以手动包含这些标题并使用它们。您可以在此处找到帮助主题和演示项目:

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

2014年3月5日更新

这个问题很久以前就被问到了,此后许多事情都发生了变化。对于那些今天(2014年初)问自己同样问题的人,我个人的回答是Qt5完全支持任务栏和各种漂亮的附加功能。有关详细信息,请参见(upd 2016年11月28日)

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

下面是一个示例代码,演示如何在Windows任务栏()中显示
QProgressBar
的值:

#ifdef_WIN32//u WIN32宏在为Windows编译时自动生成
#包括
#包括
#恩迪夫
QProgressBar*progressBar=新的QProgressBar;
progressBar->show();
#ifdef_WIN32
QWinTaskbarButton*windowsTaskbarButton=新的QWinTaskbarButton//创建显示进度的任务栏按钮
windowsTaskbarButton->setWindow(progressBar->windowHandle())//将任务栏按钮与进度条关联,假设进度条是它自己的窗口
QWinTaskbarProgress*windowsTaskbarProgress=windowsTaskbarButton->progress();
windowsTaskbarProgress->show();
QObject::connect(加载窗口和QProgressBar::值已更改,[windowsTaskbarProgress](int值){
windowsTaskbarProgress->setValue(value);//当进度条的值更改时,更改任务栏中的进度值
});
#恩迪夫

ITaskbarList3::SetProgressValue()。另请参见,其中指向一个包含同时支持KDE和Windows任务栏进度指示器的代码。(事实上,我已经在两个系统上都检查过了,可以确认它是有效的。)非常感谢。我还没有弄明白如何做到这一点,尤其是对于QtCreater,这似乎很难。也许有人能利用这个帖子:。我想我必须尝试使用Visual Studio。。。
#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