Reputation: 855
This has happened for every QDialog I pop that fires from either a mouseReleaseEvent on a QGraphicsItem or from a QContextMenu. I don't see what the issue is - the code is pretty simple..
...
void MyQGfxItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if(event->button() == Qt::RightButton)
{
MyDialog someDlg;
if(someDlg.exec())
{
}
}
}
...
As soon as the dialog is closed, either through OK or Cancel, an empty context menu appears where the event was triggered:
The blank item seems to control if my QDockWidget is hidden or visible.. Any idea what is going on? Numerous Google searches has left me stuck.
Edit - it looks like this only occurs if the Right mouse button is used..
Upvotes: 1
Views: 653
Reputation: 855
Ha! Got it. It looks like the QMainWindow grabs Right-click events after everything is finished. Calling this->setContextMenuPolicy(Qt::NoContextMenu) in the QMainWindow suppressed it.
Upvotes: 0
Reputation: 8788
According to the docs for QEvent, you should accept() events you do not want propagated to the parent widget. So somewhere in your mouseReleaseEvent, you should just add
event->setAccepted(true);
or
event->accept();
Note that you might also need to put this code in your mousePressEvent, too.
Upvotes: 2