PDA

View Full Version : Right-click menu position



thuswa
15th April 2009, 19:16
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.



self.connect(self.ui.documentlist, \
QtCore.SIGNAL('customContextMenuRequested(const QPoint &)'), \
self.showrightclickmenu)

def showrightclickmenu(self, coord):
coord = self.mapToGlobal(coord)
self.ui.menuTools.popup(coord)


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

drhex
15th April 2009, 19:56
Try opening the menu at
QCursor::pos() as suggested in the documentation for QMenu::exec()

thuswa
15th April 2009, 22:00
Try opening the menu at
QCursor::pos() as suggested in the documentation for QMenu::exec()

Ahh, that simple, it worked. Thanks!