Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Questions about Windows notifications in Qt
Forum Updated to NodeBB v4.3 + New Features

Questions about Windows notifications in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 640 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.
  • C Offline
    C Offline
    CLBSII
    wrote on 21 Jul 2021, 09:42 last edited by CLBSII
    #1

    Hi evereyone,

    I try to add some Windows notification to my application and interract with it. For that, I strated by use the good systray turorial provide by Qt.

    I use these functionalities on my program and it works well. I also add a function that create a pop up message when I click on my notification.

    However, I have some questions for which I didn't find answers:

    • The duration parameters of showMessage function doesn't seem to work on Windows 10. Is it normal ? Does it exist a solution for this ?
    • Once the notification is over, it remains on the Windows notification center (like for e-mail notifications). However, when I click on it, the associated function I created doesn't work. What is the possible solutions to make it works ?

    Note that the pop up message function works very well during the 5 second while the notification appears.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 21 Jul 2021, 10:13 last edited by
      #2

      Hi
      The docs say
      "On Windows, the millisecondsTimeoutHint is usually ignored by the system when the application has focus."
      So i don't think its "fixable"

      • Once the notification is over, it remains on the Windows notification center

      Hmm, the systray tutorial works for me and reacts to being click when inside the center.

      You could try and see if it does for you too.

      If yes, it means you have some error in the app code and if you need help to find it, you need to show it :)

      1 Reply Last reply
      1
      • C Offline
        C Offline
        CLBSII
        wrote on 21 Jul 2021, 12:30 last edited by CLBSII
        #3

        @mrjj
        Thank you for your answer. If I understand well, based on the systray tutorial code, the following lines are related to the programme reaction when the user click on the notification:

        Regarding the initialization function:

        Window::Window()
        {
        ...
        connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &Window::messageClicked);
        ...
        }
        

        Regarding the action to do on click:

        void Window::notificationClicked()
        {
            QMessageBox::information(nullptr, tr("Systray"),
                                     tr("Sorry, I already gave what help I could.\n"
                                        "Maybe you should try asking a human?"));
        }
        

        So this code works well while the notification appear, weither if I click on it directly or in the notification center. After 5 second (when the notification disappear), it still remains in the notification center, however nothing happen when I click on it (even in the systray tutorial).

        I tried it on two computer using Windows 10. Both give the same results. You say it works for you ?

        M 1 Reply Last reply 21 Jul 2021, 12:39
        0
        • C CLBSII
          21 Jul 2021, 12:30

          @mrjj
          Thank you for your answer. If I understand well, based on the systray tutorial code, the following lines are related to the programme reaction when the user click on the notification:

          Regarding the initialization function:

          Window::Window()
          {
          ...
          connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &Window::messageClicked);
          ...
          }
          

          Regarding the action to do on click:

          void Window::notificationClicked()
          {
              QMessageBox::information(nullptr, tr("Systray"),
                                       tr("Sorry, I already gave what help I could.\n"
                                          "Maybe you should try asking a human?"));
          }
          

          So this code works well while the notification appear, weither if I click on it directly or in the notification center. After 5 second (when the notification disappear), it still remains in the notification center, however nothing happen when I click on it (even in the systray tutorial).

          I tried it on two computer using Windows 10. Both give the same results. You say it works for you ?

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 21 Jul 2021, 12:39 last edited by mrjj
          #4

          @CLBSII

          Hi
          yes it works if we agree on the notification center, being this

          alt text
          it then opens a sidebar

          alt text

          and clicking on the msg there will show the same "ask a human" dialog.

          this is with Qt 5.15, Win 10 .

          So if it doesn't work for you, I would guess on older Qt, or Qt6, or the newest win 10. 21h2.

          UPDATE:
          No. i was wrong. clicking it does not trigger the dialog.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            CLBSII
            wrote on 21 Jul 2021, 12:47 last edited by CLBSII
            #5

            @mrjj
            We agree on this.
            I'm on Qt 5.12.2 and I run the program trhough Qt creator 4.15.1. My Windows version is 20H2. On the both computer where I tested it.

            So I'm a little bit confused about you saying it works on your device.

            EDIT : Ok, it is a kind of a relief. So do you have any clues why ?

            M 1 Reply Last reply 21 Jul 2021, 12:48
            0
            • C CLBSII
              21 Jul 2021, 12:47

              @mrjj
              We agree on this.
              I'm on Qt 5.12.2 and I run the program trhough Qt creator 4.15.1. My Windows version is 20H2. On the both computer where I tested it.

              So I'm a little bit confused about you saying it works on your device.

              EDIT : Ok, it is a kind of a relief. So do you have any clues why ?

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 21 Jul 2021, 12:48 last edited by
              #6

              @CLBSII

              Its not ! - sorry. it was an existing dialog that would show. it was not from clicking inside the center.

              1 Reply Last reply
              0
              • C Offline
                C Offline
                CLBSII
                wrote on 21 Jul 2021, 12:57 last edited by CLBSII
                #7

                @mrjj
                Don't worry, no problems.

                Do you know if it exists a solution to correct that ? It's a bit crippling for the users of my application.

                M 1 Reply Last reply 21 Jul 2021, 14:18
                0
                • C CLBSII
                  21 Jul 2021, 12:57

                  @mrjj
                  Don't worry, no problems.

                  Do you know if it exists a solution to correct that ? It's a bit crippling for the users of my application.

                  M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 21 Jul 2021, 14:18 last edited by
                  #8

                  @CLBSII
                  Hi
                  Sadly I was not able to find any information regarding if its should work or not or
                  it did work at some point.
                  I looked in bugs Db for QSystemTrayIcon::messageClicked
                  but I cannot find any indication of other users ever noticed this,
                  https://bugreports.qt.io/browse/QTBUG-45803?jql=text ~ "QSystemTrayIcon"

                  I wonder if something like
                  https://github.com/mohabouje/WinToast
                  could be a solution.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    CLBSII
                    wrote on 21 Jul 2021, 15:19 last edited by
                    #9

                    @mrjj
                    That is unfortunate .... anyway thank you for the help !

                    I will investigate this library. I already tried something similar in Python without success. Hoping this one will work.

                    For now I keep this topic open just in case someone find a solution to this issue.

                    1 Reply Last reply
                    1

                    1/9

                    21 Jul 2021, 09:42

                    • Login

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