PDA

View Full Version : Simulate QMenu behavior



Remenic
24th September 2009, 16:08
Hi,

I'm trying to create a popup widget that behaves exactly like a QMenu but without the items. By that, I mean the following properties:

Looks like a menu, but without the items. I guess I could use style()->drawPrimitive() to get the menu frame appearance.
Be the top-most widget.
When clicking outside the widget, the popup widget disappears, but does not "click through" (not pass the event to the widget under the cursor).


The biggest difference with a normal menu would be that my popup widget does not contain menu items, but other things.

Anyone know how to accomplish this?

Grimlock
24th September 2009, 17:52
Calling grabMouse () in showEvent() and releaseMouse () in hideEvent() or closeEvent() should do the trick of preventing other widgets form getting mouseEvents. As for the look try Qt::FramelessWindowHint window flag.
Staying on top is as easily achieved by seting the Qt::WindowStaysOnTopHint window flag.

aamer4yu
24th September 2009, 19:48
Theres also some flag - invisibletomouseevents in QWidget class,,,
not flag, rather attribute I guess... u can search for it in Qt Assistant..
May be it might help you