QApplication: modify Windows systray using QWinTaskbarButton

  • 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 (

    QWinTaskbarButton *button = new QWinTaskbarButton(widget);

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

    I would appreciate any help,

    Thanks in advance,

  • Moderators

    why don't you simply use the corresponding QML type of WinTaskbarButton?

  • Thanks!! This works!!

    My problem is that I need to show a number over the custom icon, is it possible?


  • Moderators


    1. implement a custom QQuickImageProver
    2. set the wintaksbar icon to "image://myimageprovider/icon?number=2", or also possible simply image://mytaskbarimageprovider/2 (whatever it easier for your needs)
    3. in the image provider you have to parse the received url for the number and paint it into a QPixmap and return the pixmap

  • Thanks! I will try that

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.