QMouseEvent - prevent on statusbar/menubar
I have a custom widget which reimplements QMainWindow. It has a statusbar and menubar and the main window area between. I want a context menu to appear in the main area when right clicked but not if the right click is on the status bar or menubar. How do I exclude them? I was thinking of checking the position of the click and seeing if that was within the allowed area but I'm not sure how.
Right now I'm using this:
Code:
contextMenu->exec(event->globalPos());
}
But it gives me a context menu everywhere
Thanks
Re: QMouseEvent - prevent on statusbar/menubar
Never mind, I found a solution
Code:
if(!(statusBar()->geometry().contains(pos) || menuBar()->geometry().contains(pos)))
contextMenu->exec(event->globalPos());
}