Disabling Wheel Event in a QGraphicsView ?
-
wrote on 26 Jun 2016, 15:00 last edited by
Hi Qt community ,
How to disable the wheel event in a QGraphicsView ?
Sorry for the lazy post , and thanks for your comprehension ;)
-
Hi Qt community ,
How to disable the wheel event in a QGraphicsView ?
Sorry for the lazy post , and thanks for your comprehension ;)
wrote on 26 Jun 2016, 15:07 last edited by Joel BodenmannAs 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 { Q_OBJECT public: explicit MyGraphicsView(QWidget* parent = nullptr) : QGraphicsView(parent) {} protected: virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE { event->accept(); } };
-
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 { Q_OBJECT public: explicit MyGraphicsView(QWidget* parent = nullptr) : QGraphicsView(parent) {} protected: virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE { event->accept(); } };
wrote on 26 Jun 2016, 16:05 last edited by WaluxThanks for this unique answer .
Actually , i figured out myself an another solution :
void Scene::wheelEvent(QGraphicsSceneWheelEvent *event) { event->accept(); }
Probably not as good , so i'll use yours .
topic->setAsSolved(true);
-
Thanks for this unique answer .
Actually , i figured out myself an another solution :
void Scene::wheelEvent(QGraphicsSceneWheelEvent *event) { event->accept(); }
Probably not as good , so i'll use yours .
topic->setAsSolved(true);
@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).
4/4