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] Keyboard modifiers with QWheelEvent on MacOS
Forum Updated to NodeBB v4.3 + New Features

[Solved] Keyboard modifiers with QWheelEvent on MacOS

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 3.8k 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.
  • U Offline
    U Offline
    Uflex
    wrote on last edited by
    #1

    Hi there,

    I've got a cross platform application using the mouse wheel combined with the "alt modifier":http://qt-project.org/doc/qt-5.1/qtcore/qt.html#KeyboardModifier-enum but it doesn't work on Mac OSX, only on Windows. Here is a simplified code:

    @void MyGraphicsView::wheelEvent(QWheelEvent *event)
    {
    qDebug() << event->modifiers();
    }@

    Nothing is displayed on Mac but on Windows it works fine, have I forgot something?

    EDIT: This bug is already known: https://bugreports.qt-project.org/browse/QTBUG-32098

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What version of Qt are you using on what version of OS X ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • U Offline
        U Offline
        Uflex
        wrote on last edited by
        #3

        Sorry, forgot to mention that: osx 10.8 and Qt5.1

        1 Reply Last reply
        0
        • U Offline
          U Offline
          Uflex
          wrote on last edited by
          #4

          I just tried with a simple program and it seems to not work either. The modifiers are set in the mousePressEvent but not for the wheelEvent:

          @#include <QMainWindow>
          #include <QDebug>
          #include <QWheelEvent>
          #include <QMouseEvent>

          class MainWindow : public QMainWindow
          {
          Q_OBJECT

          // QWidget interface
          

          protected:
          void wheelEvent(QWheelEvent *event)
          {
          qDebug() << "wheelEvent" << event->modifiers();
          }

          void mousePressEvent(QMouseEvent *event)
          {
              qDebug() << "mousePressEvent" << event->modifiers();
          }
          

          };
          @

          Possible output:

          bq. mousePressEvent QFlags(0x4000000)
          mousePressEvent QFlags(0x4000000|0x8000000)
          mousePressEvent QFlags(0x4000000|0x8000000|0x10000000)
          wheelEvent QFlags()
          wheelEvent QFlags()
          wheelEvent QFlags()
          wheelEvent QFlags()
          wheelEvent QFlags()

          I'm downloading Qt 4.8.5 on Mac but the same code definitely works on Windows 7, with both Qt 4.8.4 and Qt 5.1

          Could that be a bug in Qt 5/5.1?

          1 Reply Last reply
          0
          • U Offline
            U Offline
            Uflex
            wrote on last edited by
            #5

            I just found this: https://bugreports.qt-project.org/browse/QTBUG-29820

            It seems to be a bug in 5.1, can anybody reproduce it? The project linked to the bug report didn't work for me on OSX 10.8 with Qt 5.1.0

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What didn't work ?
              I just tested it on 10.6.8 with both 4.8.6 and 5.1.2 (git build) and it seems to work using the scroll from a trackpad

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • U Offline
                U Offline
                Uflex
                wrote on last edited by
                #7

                Pressing any modifier with the mouse wheel wasn't displaying anything. I have a pc mouse (3 buttons). It works for mousePressEvent though.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I'll test again when I can get my hands on a mouse

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • U Offline
                    U Offline
                    Uflex
                    wrote on last edited by
                    #9

                    I just tried with a "mighty mouse":http://en.wikipedia.org/wiki/Apple_Mighty_Mouse and have the same behaviour: no modifier seem to be detected in wheelEvent (but they all are in mousePressEvent).

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      sebr
                      wrote on last edited by
                      #10

                      This is a reported bug:
                      https://bugreports.qt-project.org/browse/QTBUG-32098

                      You can use my patch to fix this behavior.

                      1 Reply Last reply
                      0
                      • U Offline
                        U Offline
                        Uflex
                        wrote on last edited by
                        #11

                        Oh yeah, don't know why but I missed that one, even if there are not that many results for "wheelEvent modifiers"...

                        Thanks, I'll look into that patch.

                        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