Morea
14th January 2007, 15:43
void Fraga::contextMenuEvent(QGraphicsSceneContextMenuE vent* e)
{
QMenu menu;
QPoint p= (mapToParent(e->scenePos())).toPoint();
menu.addAction(_nyttsvar);
menu.exec( p );
}
Fraga is an QGraphicsRectItem. This is the code, but it doesn't seem to get maped to the correct coordinatesystem. A call to the above function places the menu outside of the Mainwindow, which is not exactly what I had hoped for.
The menu should be placed close to the mouse cursor, of course. But I don't know how.
{
QMenu menu;
QPoint p= (mapToParent(e->scenePos())).toPoint();
menu.addAction(_nyttsvar);
menu.exec( p );
}
Fraga is an QGraphicsRectItem. This is the code, but it doesn't seem to get maped to the correct coordinatesystem. A call to the above function places the menu outside of the Mainwindow, which is not exactly what I had hoped for.
The menu should be placed close to the mouse cursor, of course. But I don't know how.