PDA

View Full Version : QApplication: modify Windows systray using QWinTaskbarButton



ddonate
7th September 2017, 13:05
Hi,

I have a QT application (QT .9.1) and I need to modify the icon in the windows taskbar, when I have an error. I am trying with QWinTaskbarButton, it seems to be really simple but I failed.

My application is a QtQuickControlsApplication (a QApplication), where I have a manager QObject class.

In this class I create a QQmlApplicationEngine, which I use to load the main QML.

From the documentation (http://doc.qt.io/qt-5/qwintaskbarbutton.html#details):


QWinTaskbarButton *button = new QWinTaskbarButton(widget);
button->setWindow(widget->windowHandle());
button->setOverlayIcon(QIcon(":/loading.png"));

But i don't know what to set in 'widget' and 'widget->windowHandle()'

I have tried to get a widget from the qApp but failed:

qApp->activeWindow() is NULL
qApp->topLevelWindows().at(0) is valid, but failed:

QWinTaskbarButton *button = new QWinTaskbarButton(qApp->topLevelWindows().at(0));
button->setWindow(qApp->allWidgets().at(0)->windowHandle());
button->setOverlayIcon(QIcon(":/images/icon.png"));

I would appreciate any help,

Thanks in advance,
Diego

ddonate
8th September 2017, 11:06
I get the icon using the corresponding QML type of WinTaskbarButton. But I need to show a number over the icon, is it possible? Thanks