PDA

View Full Version : Passing a QMouseEvent to a QGraphicsScene



ferebia
21st June 2016, 19:17
I created a qGLWidget that is the parent to a QGraphicsScene, I have bypassed the use of a qGraphicsView. Ive read that a qGraphicsView handles all the mouse events for a qGraphicsScene and passes the events to it after making it into a qgraphicscenemouseevent.

Ive looked through the source for change between a QMouseEvent and a QGraphicsSceneMouseEvent and I am attempting to use that as my basis for creating a qgraphicsscenemouseevent from the qglwidget. I would like to know it is even possible to pass a mouse event from a qglwidget to qgraphicsscene? and how to pass?

Ginsengelf
22nd June 2016, 08:21
Hi, you could use QCoreApplication::postEvent or QCoreApplication::sendEvent to send events to the QGraphicsScene.

Ginsengelf

ferebia
22nd June 2016, 19:50
Does the type of event matter? I am getting a QMouseEvent, and from what i understand a QGraphicsScene requires a QGraphicsSceneMouseEvent.

ferebia
24th June 2016, 15:48
I was able to get my scene to accept the the mouse event using a QCoreApplication::sendEvent however it is not passing the event down to my qgraphicsitems do i follow the same process for the items or is there a way to send from the scene?

anda_skoa
24th June 2016, 16:07
When you write "I was able to get my scene to accept the the mouse event" do you mean that it created the respective QGraphicsSceneMouseEvent?

Because my understanding was that this is done by the view.

Cheers,
_