[PyQt] Context menu on items in QTreeView

Phil Thompson phil at riverbankcomputing.com
Tue Oct 14 21:47:53 BST 2008


On Tue, 14 Oct 2008 22:30:03 +0200, "Filip Gruszczyński"
<gruszczy at gmail.com> wrote:
> Hello,
> 
> I would like to pop up a menu on items in QTreeView. I decided to
> intercept pressed(const QModelIndex&) signal, because contextMenuEvent
> doesn't provide information about the tree view chosen index.

Have a look at QAbstractItemView.indexAt()

> However,
> inside the slot for this signal I cannot acces position of the mouse
> (no event) and decide, where to pop this menu. I tried browsing
> QApplication class, but found no information about the global mouse
> position (though there is global information about buttons pressed).
> Is there anyway to obtain it and popup menu in the right place?

Phil


More information about the PyQt mailing list