How to show progress in windows 7 taskbar (using Qt)?

前端 未结 2 707
感动是毒
感动是毒 2021-02-07 07:04

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. S

相关标签:
2条回答
  • 2021-02-07 07:19

    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
    
    0 讨论(0)
  • 2021-02-07 07:23

    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

    0 讨论(0)
提交回复
热议问题