Disabling Wheel Event in a QGraphicsView ?

  • Hi Qt community ,

    How to disable the wheel event in a QGraphicsView ?

    Sorry for the lazy post , and thanks for your comprehension ;)

  • As there is no property to enable or disable it you have to create a subclass and overwrite the implementation of the corresponding wheelEvent(). Something along the lines of:

    class MyGraphicsView : public QGraphicsView
    	explicit MyGraphicsView(QWidget* parent = nullptr) : QGraphicsView(parent) {}
    	virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE {

  • @Joel-Bodenmann

    Thanks for this unique answer .

    Actually , i figured out myself an another solution :

    void Scene::wheelEvent(QGraphicsSceneWheelEvent *event)

    Probably not as good , so i'll use yours .


  • Moderators

    @Walux said:

    Probably not as good , so i'll use yours .

    just for clarification:
    Actually this is exactly the same approach, just a step later.
    (After the graphics view translated and forwarded it's received events to it's scene).

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.