PDA

View Full Version : Disable left click menu on icon



atlantis210
22nd December 2014, 10:55
Hi everyone,

I'd like to disable the menu displayed when you left-click on the icon of a QWidget.
The thing is I thought it was a contextMenu since it's the same menu that is displayed but seems not...
I tried to overload mousePressEvent, install a eventfilter... but with no success (nor did the search on google)

The eventfilter works but not on the first attempt. By that I mean, on the first left click on the icon, it displays the menu but on the second click it's not available. But if you move your mouse and click on another pixel of the icon it displays the menu but not on the second etc...

So if anyone has any idea...

Edit:
I tried using
mSubWindow->setWindowFlags(Qt::WindowStaysOnTopHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
But it also remove the icon and the close button (Qt::WindowSystemMenuHint being needed on my plateform obviously...)

Or if not possible to disable the menu, is it possible to disable "move" and "size" of this menu actions instead?

atlantis210
22nd December 2014, 17:14
I succeeded to disable the left click menu by intercepting the event with an eventFilter. It didn't work at first because my eventFilter was set on the main widget and not on the child...
Anyhow, it works.