Results 1 to 3 of 3

Thread: Simulate QMenu behavior

  1. #1
    Join Date
    Feb 2006
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Simulate QMenu behavior

    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?

  2. #2
    Join Date
    Nov 2008
    Location
    Częstochowa/Poland
    Posts
    50
    Thanks
    2
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simulate QMenu behavior

    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.
    Last edited by Grimlock; 24th September 2009 at 18:39.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Simulate QMenu behavior

    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

Similar Threads

  1. QMenu popup: how close when clicked outside
    By powermax in forum Qt Programming
    Replies: 5
    Last Post: 4th March 2009, 03:18
  2. Weird QMenu behavior on Mac
    By munna in forum Qt Programming
    Replies: 1
    Last Post: 14th January 2009, 15:18
  3. QStyle : how to make the QMenu display in middle?
    By nish in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 27th November 2008, 10:39
  4. Counter-intuitive behavior of QThreads signals/slots
    By reddish in forum Qt Programming
    Replies: 3
    Last Post: 9th September 2008, 20:40
  5. how to popup and close a QMenu
    By Placido Currò in forum Qt Programming
    Replies: 15
    Last Post: 14th May 2007, 16:41

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.