[PyQt] Signal on Selection in QTreeView

Andreas Pakulat apaku at gmx.de
Mon Mar 17 18:16:02 GMT 2008

On 17.03.08 10:22:05, fossks at cox.net wrote:
> Hi,
>   I'm trying to use a list that contains a media library react to a user clicking on an item in the list.  When clicked, the details of the item would show up in a GroupBox elsewhere on the screen.  However, at this time I'm a little stumped on Lists/Trees/Models/Views.
>    I'm including the function that is called when the library is opened.  You can see that I have a connection to the listview call (self.lv).   I also have a backup in case this doesn't work which is a button to get the details.  However, I would like to have it such that whichever item is selected/highlighted, would get shown in the item details group box.
>   I've likely missed the implementation of this by a mile, and I need some help.    I've checked for examples but either they don't seem to do the same as I want or they are too complicated.
>   Please let me know if anyone has some advice.

So what exactly is your problem?

> 	self.lv = QTreeView()
> 	self.connect(self.lv, SIGNAL("currentTextChanged(const QString&)"), self.item_selected)

This won't work. There's no such signal on a QTreeView. You should look
up the API in the PyQt docs (or Qt docs) to see which kind of signal you
can use. Probably though you need to connect to the SelectionModel of
your treeview to get notified about selection changes. See


You will be aided greatly by a person whom you thought to be unimportant.

More information about the PyQt mailing list