[PyQt] selecting an item in qtreeview

Paul Du Bois dubois at doublefine.com
Thu Jun 30 02:28:21 BST 2011


I use QTreeView's selectionChanged signal.  But you should also look at
QAbstractItemView's signals; it has many for you to choose from:
activated, clicked, doubleClicked, entered, pressed, ...

 

p

 

From: pyqt-bounces at riverbankcomputing.com
[mailto:pyqt-bounces at riverbankcomputing.com] On Behalf Of Jason Rahm
Sent: Wednesday, June 29, 2011 3:03 PM
To: Jason Rahm; pyqt at riverbankcomputing.com
Subject: Re: [PyQt] selecting an item in qtreeview

 

Sorry, forgot to include specs: PyQt version is 4.7, python is 2.7.1.

 

From: pyqt-bounces at riverbankcomputing.com
[mailto:pyqt-bounces at riverbankcomputing.com] On Behalf Of Jason Rahm
Sent: Wednesday, June 29, 2011 3:48 PM
To: pyqt at riverbankcomputing.com
Subject: [PyQt] selecting an item in qtreeview

 

When using qtreewidget, I can use the itemClicked method to then call a
def:

 

self.treeWidget_iRulesList.itemClicked.connect(self.displayRule)

 

However, I hit a wall in trying to pass data around this way, so I
watched some tutorials on how to set up a model view and abstract the
data from the GUI components.  This involved switching from a treeWidget
to a treeView.  This works great in populating the tree, but now I don't
know how to signal a clicked item and pass that item (and the tree
parent it belongs to) to my displayRule def.  Any thoughts?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110629/3ad43241/attachment.html>


More information about the PyQt mailing list