I followed the examples I found to make use of the QWinTaskbarProgress
. I created a standard Qt Widgets Application
in Qt Creator
(Qt 5.3.1) and my mainwindow.cpp
looks like this:
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_taskbarButton = new QWinTaskbarButton(this);
m_taskbarButton->setWindow(windowHandle());
m_taskbarButton->setOverlayIcon(style()->standardIcon(QStyle::SP_MediaPlay));
m_taskbarProgress = m_taskbarButton->progress();
m_taskbarProgress->setVisible(true);
m_taskbarProgress->setRange(0, 100);
m_taskbarProgress->setValue(50);
}
MainWindow::~MainWindow()
{
delete ui;
}
I expected the task bar icon to be overlaid and showing 50%
progress bar after starting the application, but the task bar looks normal, just as if did not code anything. What am I doing wrong?
In fact, it seems like calling "m_taskbarButton->setWindow(windowHandle());" in QMainWindow constructor doesn't work and QWinTaskbarProgress won't show at all even after calling setVisible(true) or show().
It has to be called once the Window is shown like in :
void MainWindow::showEvent(QShowEvent *e)
{
#ifdef Q_OS_WIN32
m_taskbarButton->setWindow(windowHandle());
#endif
e->accept();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With