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] Can't catch event
Qt 6.11 is out! See what's new in the release blog

[SOLVED] Can't catch event

Scheduled Pinned Locked Moved General and Desktop
14 Posts 6 Posters 7.3k Views 2 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.
  • M Offline
    M Offline
    maxim.prishchepa
    wrote on last edited by
    #1

    Hi All!
    I have @class MainWindow: public QMainWindow@ MainWindow has QSystemTrayIcon as member, in constructor MainWindow's i do @m_trayIcon.installEventFilter(this);@ and try catch the event at @protected: bool eventFilter(QObject *obj, QEvent *ev);@ in MainWindow, but nothing happens. I do this because need analyses some variables and set enable\disable some actions in ContextMenu, who's call at second mouse button click at tray icon. What i do wrong, and maybe some one know ease way to solve this problem?

    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      Can you show body of your eventFilter method?

      --
      Vasiliy

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxim.prishchepa
        wrote on last edited by
        #3

        something like that:
        @bool eventFilter(QObject *obj, QEvent *ev){
        int someOperationForBreakpoint = 0; //hear i try to see breakpoint int debugger
        return __super::eventFilter(obj, ev);
        }@

        full code stay at work, and i can't show them from home.

        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

        1 Reply Last reply
        0
        • L Offline
          L Offline
          loladiro
          wrote on last edited by
          #4

          QSystemTrayIcon is not a widget and therefore does not receive UI related events such as click events, show events, etc (That all handled by the OS, not Qt). You should use the "activated() signal":http://doc.qt.nokia.com/4.7-snapshot/qsystemtrayicon.html#activated instead.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maxim.prishchepa
            wrote on last edited by
            #5

            Tnx, a lot!

            Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

            1 Reply Last reply
            0
            • A Offline
              A Offline
              anshah
              wrote on last edited by
              #6

              I am having trouble capturing events in Ubuntu 17.04 Unity Desktop because of the following bug:

              https://bugreports.qt.io/browse/QTBUG-26841

              The activated SIGNAL does not go out. I tried mouse click event capture and everything and nothing works. Is there a workaround?

              jsulmJ 1 Reply Last reply
              0
              • A anshah

                I am having trouble capturing events in Ubuntu 17.04 Unity Desktop because of the following bug:

                https://bugreports.qt.io/browse/QTBUG-26841

                The activated SIGNAL does not go out. I tried mouse click event capture and everything and nothing works. Is there a workaround?

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @anshah The bug you meantioned was fixed in Qt 5.4. Which Qt version do you use? Also which signals do not work for you?

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                A 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @anshah The bug you meantioned was fixed in Qt 5.4. Which Qt version do you use? Also which signals do not work for you?

                  A Offline
                  A Offline
                  anshah
                  wrote on last edited by
                  #8

                  @jsulm Wow thanks for responding. I'm using Ubuntu 17.04 with Qt 5.11 latest and I'm only seeing the activated signal not going out on the Unity desktop (Ubuntu default). The signal goes out fine on Plasma KDE and Gnome desktops. I just want to be able to click on the QSystemTrayIcon and have a window pop up and I can't even do that. Is there any workaround?

                  jsulmJ 1 Reply Last reply
                  0
                  • A anshah

                    @jsulm Wow thanks for responding. I'm using Ubuntu 17.04 with Qt 5.11 latest and I'm only seeing the activated signal not going out on the Unity desktop (Ubuntu default). The signal goes out fine on Plasma KDE and Gnome desktops. I just want to be able to click on the QSystemTrayIcon and have a window pop up and I can't even do that. Is there any workaround?

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @anshah Do you use Qt provided by Ubuntu?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    A 2 Replies Last reply
                    0
                    • jsulmJ jsulm

                      @anshah Do you use Qt provided by Ubuntu?

                      A Offline
                      A Offline
                      anshah
                      wrote on last edited by
                      #10

                      @jsulm I installed Qt 5.11 on Ubuntu.

                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @anshah Do you use Qt provided by Ubuntu?

                        A Offline
                        A Offline
                        anshah
                        wrote on last edited by
                        #11

                        @jsulm I'll be happy if the QSystemTrayIcon can somehow capture mouse click events. It is not a QWidget so that has been difficult as well. What is happening is that both left/right clicks on Ubuntu Unity pop up a context menu. This is a known issue along with the activated signal not going out.

                        mrjjM 1 Reply Last reply
                        0
                        • A anshah

                          @jsulm I'll be happy if the QSystemTrayIcon can somehow capture mouse click events. It is not a QWidget so that has been difficult as well. What is happening is that both left/right clicks on Ubuntu Unity pop up a context menu. This is a known issue along with the activated signal not going out.

                          mrjjM Offline
                          mrjjM Offline
                          mrjj
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Hi
                          Did you install Qt5.11 from Qt site or via apt-get ?
                          I recall cases from other posters where vanilla Qt from Qt site would
                          have issues with the Main Menus, but using the distro provided
                          Qt would actually work as intended.

                          A 1 Reply Last reply
                          0
                          • mrjjM mrjj

                            Hi
                            Did you install Qt5.11 from Qt site or via apt-get ?
                            I recall cases from other posters where vanilla Qt from Qt site would
                            have issues with the Main Menus, but using the distro provided
                            Qt would actually work as intended.

                            A Offline
                            A Offline
                            anshah
                            wrote on last edited by
                            #13

                            @mrjj It is definitely the vanilla Qt from the site. Let me uninstall and retry with apt-get. Thanks for the response!

                            1 Reply Last reply
                            0
                            • A Offline
                              A Offline
                              anshah
                              wrote on last edited by
                              #14

                              I just installed Qt on Ubuntu using apt-get but apt-get only has 5.7 instead of 5.11.
                              Different behavior:

                              • icon shows up as blank in the system tray (triangle with exclamation in the middle)
                              • Menu Item contains "Activate" because I updated sni-qt.conf

                              It still doesn't solve my problem. I want the QSystemTrayIcon::activated to go out on left click or capture the left click somehow. I don't want to see an menu at all on left click.

                              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