Results 1 to 3 of 3

Thread: Right-click menu position

  1. #1
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Right-click menu position

    Asked the same question in another qt forum, trying this one as well...

    Working on a project http://code.google.com/p/subdms/ where I'm using pyqt4 for creating the user interface. I think my question is a general Qt-question the fact that I'm using pyqt4 does not matter.

    I have a question regarding positioning of a right-click menu. I can't for my life get the menu to popup on the lower right side of the mouse pointer, instead it is positioned dead center under the mouse pointer. How do I get the the correct positioning of the menu?

    Here is the code snipet. Guess that mapToGlobal should be something else, or something more added to this statement.

    Qt Code:
    1. self.connect(self.ui.documentlist, \
    2. QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), \
    3. self.showrightclickmenu)
    4.  
    5. def showrightclickmenu(self, coord):
    6. coord = self.mapToGlobal(coord)
    7. self.ui.menuTools.popup(coord)
    To copy to clipboard, switch view to plain text mode 

    Thanks for your help, I'm really stuck on this one.

  2. #2
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Right-click menu position

    Try opening the menu at
    Qt Code:
    1. QCursor::pos()
    To copy to clipboard, switch view to plain text mode 
    as suggested in the documentation for QMenu::exec()

  3. The following user says thank you to drhex for this useful post:

    thuswa (15th April 2009)

  4. #3
    Join Date
    Apr 2009
    Posts
    3
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Right-click menu position

    Quote Originally Posted by drhex View Post
    Try opening the menu at
    Qt Code:
    1. QCursor::pos()
    To copy to clipboard, switch view to plain text mode 
    as suggested in the documentation for QMenu::exec()
    Ahh, that simple, it worked. Thanks!

Similar Threads

  1. rigth click of mouse to create sub menu
    By SunnySan in forum Qt Programming
    Replies: 8
    Last Post: 12th November 2008, 11:29
  2. Word at mouse click position in QGraphicsTextItem
    By pherthyl in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2008, 04:56
  3. QTableWidget right click menu
    By stefan in forum Newbie
    Replies: 5
    Last Post: 23rd June 2008, 19:42
  4. Replies: 2
    Last Post: 2nd April 2008, 17:28
  5. Right click menu
    By ^NyAw^ in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:22

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.