Unsolved QMousePressEvent on QGraphicsView
-
Good evening. Help to intercept the mouse click on QGraphicsView (which includes QGraphicsScene).
There is a function: void mousePressEvent (QMouseEvent * mouseEvent) override.
It intercepts the mouse event, but it does not intercept if the event occurs in QGraphicsView. -
Hi,
If you want to get the event that are happening in the scene, you need to subclass QGraphicsScene and reimplement QGraphicsScene::mousePressEvent.
-
@SGaist Thanks, I'll try to do.
-
Hi
When learning how the coordinates works i used thisclass CustomScene : public QGraphicsScene { protected: void mousePressEvent(QGraphicsSceneMouseEvent* event) { QGraphicsScene::mousePressEvent(event); qDebug() << event->scenePos(); } };
Not sure what you are looking for but this is minimal sample of getting clicks.