Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QApplication: modify Windows systray using QWinTaskbarButton
Forum Updated to NodeBB v4.3 + New Features

QApplication: modify Windows systray using QWinTaskbarButton

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Diego DonateD Offline
    Diego DonateD Offline
    Diego Donate
    wrote on last edited by
    #1

    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

    raven-worxR 1 Reply Last reply
    0
    • Diego DonateD Diego Donate

      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

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Diego-Donate
      why don't you simply use the corresponding QML type of WinTaskbarButton?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • Diego DonateD Offline
        Diego DonateD Offline
        Diego Donate
        wrote on last edited by
        #3

        Thanks!! This works!!

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

        Regards,
        Diego

        raven-worxR 1 Reply Last reply
        0
        • Diego DonateD Diego Donate

          Thanks!! This works!!

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

          Regards,
          Diego

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @Diego-Donate

          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

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0
          • Diego DonateD Offline
            Diego DonateD Offline
            Diego Donate
            wrote on last edited by
            #5

            Thanks! I will try that

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved