Qt QOpenGLWidget wheelEvent strange behaviour

前端 未结 3 1811
北荒
北荒 2021-01-15 02:26

I have the following class :

class Curve2DOpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core {
Q_OBJECT   
public:

    Curve2DOpenGLWi         


        
相关标签:
3条回答
  • 2021-01-15 02:48

    From Qt documentation

    Mouse events occur when a mouse button is pressed or released inside a widget, or when the mouse cursor is moved.

    Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking().

    So you need setMouseTracking(true) in your constructor

    0 讨论(0)
  • 2021-01-15 02:54

    I did run into the same problem.

    In my case it was a QTimer based render loop which was updating 4 QOpenGLWidgets and the window’s title bar (which was actually pretty CPU intensive) at 100 FPS.
    It didn’t manifest on Windows, but on Linux.

    The update events for the qoglwidgets and the mouse move events probably have higher priority in the event loop than the wheel events. The wheel events don’t seem to be dropped but are accumulated and arrive together with next event that »gets through«.

    Luckily the use case allowed to replace this render loop with an event driven implementation avoiding this issue.

    0 讨论(0)
  • 2021-01-15 03:00

    See Qt::AA_CompressHighFrequencyEvents and Qt::AA_CompressTabletEvents in http://doc.qt.io/qt-5/qt.html#ApplicationAttribute-enum

    These are new attributes in Qt 5.

    0 讨论(0)
提交回复
热议问题