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. [Solved] Using QSystemTrayIcon with an application based on QQmlApplicationEngine
Forum Update on Monday, May 27th 2025

[Solved] Using QSystemTrayIcon with an application based on QQmlApplicationEngine

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 1.4k Views
  • 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
    cristeab
    wrote on last edited by cristeab
    #1

    Hi

    I have an application developed with Qt5.4. In main file I am using QQmlApplicationEngine to load directly the UI from QML file. My problem is that I need to minimise this application to tray icon, however I don't see how to use QSystemTrayIcon from my application, written mostly in QML. Could you advise ?

    thanks
    Bogdan

    p3c0P 1 Reply Last reply
    0
    • C cristeab

      Hi

      I have an application developed with Qt5.4. In main file I am using QQmlApplicationEngine to load directly the UI from QML file. My problem is that I need to minimise this application to tray icon, however I don't see how to use QSystemTrayIcon from my application, written mostly in QML. Could you advise ?

      thanks
      Bogdan

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @cristeab I think you will need to subclass QQmlApplicationEngine and load the QML there. In this way you will able to add QSystemTrayIcon there. Get the top window using rootObjects and cast it to QQuickWindow. Now the problem I guess would be to trap close event in order hide the window when close is clicked. QQuickWindow has closing signal but can't use it since QQuickCloseEvent is not public yet. So one way would be to use eventFilter for QQuickWindow object and look out for close event and ignore it and hide the window.
      Can you try this ?

      157

      1 Reply Last reply
      0
      • C Offline
        C Offline
        cristeab
        wrote on last edited by
        #3

        Hi

        I have been able to create a QSystemTrayIcon without deriving from QQmlApplicationEngine. I get with rootObjects() a pointer to QQuickWindow, but when I try to show a message using QSystemTrayIcon the entire application crashes. It doesn't matter if QSystemTrayIcon parent is QQuickWindow or NULL, in both cases I get a crash.

        regards
        Bogdan

        p3c0P 1 Reply Last reply
        0
        • C cristeab

          Hi

          I have been able to create a QSystemTrayIcon without deriving from QQmlApplicationEngine. I get with rootObjects() a pointer to QQuickWindow, but when I try to show a message using QSystemTrayIcon the entire application crashes. It doesn't matter if QSystemTrayIcon parent is QQuickWindow or NULL, in both cases I get a crash.

          regards
          Bogdan

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @cristeab Can you post the relevant code ?

          157

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cristeab
            wrote on last edited by cristeab
            #5

            I have found the problem: I should instantiate a QApplication object instead of QGuiApplication in my main function. Thanks for your help.

            p3c0P 1 Reply Last reply
            0
            • C cristeab

              I have found the problem: I should instantiate a QApplication object instead of QGuiApplication in my main function. Thanks for your help.

              p3c0P Offline
              p3c0P Offline
              p3c0
              Moderators
              wrote on last edited by
              #6

              @cristeab Ok. So does it not crash now ?

              157

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cristeab
                wrote on last edited by cristeab
                #7

                Actually I don't need to subclass from QQmlApplicationEngine in order to create a system icon, but I must use QApplication, otherwise the application will crash.

                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