Results 1 to 6 of 6

Thread: Independent Right-Click Menus

  1. #1
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Independent Right-Click Menus

    Let me first say I've been using this forum passively for a while now and it has proved to be an invaluable resource in solving the majority of my PyQt questions. Now onto my main problem... I am currently developing an application that allows the user to distribute a frame sequence (3d rendering) across multiple computers for rendering. This application allows the user to not only view the current frames being rendered but also the connected hosts. Initially I was going to use a set of menus and buttons to control the tables then I realized it made more sense to create a right-click drop down menu. My main problem is that I cannot figure out a few things:

    1.) ONLY popup the drop down menu IF it is over one of the table widgets (or perhaps more specifically, any row)
    2.) Create individual menu sets for each table widget.
    3.) Menu sets are based off of current information. For example, if the host is inactive you can only activate the host. (this is easy using if/else statements, I just need the get #1/2 working)

    Other Items:
    1.) If you don't know anything about PyQt please answer anyway as most of the information will carry over to Python.

    2.) The gui was created using Qt Designer so all widgets are referenced using self.ui.<widget_name>

    Thank you in advance for your help!


  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Independent Right-Click Menus

    Ok, but what exactly is the problem? What is that you don't know how to do?

  3. #3
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Independent Right-Click Menus

    If I use contextMenuEvent to create the pop up menu the menu will appear where ever and when ever the right mouse button is clicked, even outside of the tables. What I want to be able to do is pop up the menu only if the mouse button was pressed over a table widget. Secondly, I would like to be able to create individual menus for each table widget.

    Example 1: User click the right mouse button over the main window but not over one of the tables, nothing happens as a result.

    Example 2: User clicks the right mouse button over the host table and a menu containing several actions specific to host management pops up under the mouse cursor.

  4. #4
    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: Independent Right-Click Menus

    Where are you catching the contextmenu event and showing the context menu ?
    You can always check if an item exists under the mouse pos and show menu only in that case

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Independent Right-Click Menus

    read this thread, it should help you QTreeWidget & context menu
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. The following user says thank you to spirit for this useful post:

    HiFly (20th February 2009)

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Independent Right-Click Menus

    Quote Originally Posted by HiFly View Post
    What I want to be able to do is pop up the menu only if the mouse button was pressed over a table widget.
    So reimplement contextMenuEvent() for that widget.

    Secondly, I would like to be able to create individual menus for each table widget.
    Then do it, what is the problem? Subclass the table widget and reimplement its event handler or use a different QWidget::contextMenuPolicy to avoid subclassing tables.

Similar Threads

  1. Double Click Capturing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2011, 14:12
  2. Right click list - some advice ?
    By aurelius in forum Qt Programming
    Replies: 5
    Last Post: 27th January 2009, 07:04
  3. Maya Style Right Click Menus in Qt
    By dvmorris in forum Qt Programming
    Replies: 1
    Last Post: 13th April 2007, 11:55
  4. QGraphicsScene Click / Double Click
    By philentropist in forum Qt Programming
    Replies: 1
    Last Post: 9th February 2007, 04:32
  5. More problems with Menus and Toolbars
    By mridey in forum Qt Tools
    Replies: 2
    Last Post: 16th November 2006, 11:37

Tags for this Thread

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.