开发者

QPoint for context menu position

I generate these i buttons:

self.connect(self.ui.pushButton_i, QtCore.SIGNAL('customContextMenuRequested(const QPoint)'), self.on_context_menu)

The buttons are paced开发者_如何学Go in a gridLayout. The position of the contextMenu horizontal is OK but the vertical position is always on the lowest of the buttons.

How can I make sure the contextMenu postion is just right below the cursor (the standaard position) ?


What I did is to ask the object that creates the contextMenu to map the mouse coordinate to a global coordinate:

      self.editorContextMenu.exec_(self.confEditorTree.mapToGlobal(point))

Here editorContextMenu being the the contextMenu itself and self.confEditorTree being the thing that was clicked on. So in you're case you might have to ask the pushButtons to map the mouse coordinates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜