Hi,
i'm trying to send custom events into an existing QGraphicsScene. first event is being fired in the scene with the desired location. from now on, all other events go to the same location (as the first event) even if they were provided with other locations. after i manually click somewhere inside the scene, it "restarts" and the next custom event is accepted in the right location (all others still go to the wrong place).
my code:
qreal sceneX = customX;
qreal sceneY = customY;
QGraphicsView* view = m_scene->views()[0];
QPoint ptView = view->mapFromScene(sceneX, sceneY);
QPoint ptGlobal = view->viewport()->mapToGlobal(ptView);
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease);
event.setScenePos(QPoint(sceneX, sceneY));
event.setPos(QPoint(sceneX, sceneY));
event.setScreenPos(ptGlobal);
event.setButton(Qt::LeftButton);
event.setButtons(Qt::LeftButton);
event.setModifiers(QApplication::keyboardModifiers());
qApp->sendEvent(m_scene, &event);
customX and customY are just arbitrary x and y that i generate on the fly. i send the sample code many time with different customX and customY.