[Solved] Keyboard modifiers with QWheelEvent on MacOS
-
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
-
Hi,
What version of Qt are you using on what version of OS X ?
-
Sorry, forgot to mention that: osx 10.8 and Qt5.1
-
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?
-
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
-
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 -
Pressing any modifier with the mouse wheel wasn't displaying anything. I have a pc mouse (3 buttons). It works for mousePressEvent though.
-
I'll test again when I can get my hands on a mouse
-
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).
-
This is a reported bug:
https://bugreports.qt-project.org/browse/QTBUG-32098You can use my patch to fix this behavior.
-
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.