Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

windows-7

qt

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)?

like image 882
Nedec Avatar asked Dec 03 '10 20:12

Nedec


2 Answers

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

like image 64
Pie_Jesu Avatar answered Sep 22 '22 17:09

Pie_Jesu


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
like image 42
Donald Duck Avatar answered Sep 26 '22 17:09

Donald Duck