[PyQt] QTreeWidget and item parents
Jamie Riotto
jamie.riotto at gmail.com
Thu Aug 27 17:29:35 BST 2009
Scott,
simply do:
print self.theTree.currentItem().text(0)
index = self.theTree.currentIndex()
print "row: ", index.row() # returns row number
relative to branch parent
NEW>>> print "parent", index.parent()
Cheers - jamie
On Thu, Aug 27, 2009 at 8:46 AM, Scott Frankel<frankel at circlesfx.com> wrote:
>
> Hello,
>
> How would one identify the parent of a selected item in a QTreeWidget?
>
> I have a tree with several branches. Each branch contains leaves with the
> same names. (See attached sample code.) I'd like to be able to identify
> that the leave item selected, say "Bbbb," was picked from branch "Three."
>
> I'm identifying the selected leaf item with currentItem(). (See line 126 in
> pickItem()). The currentIndex() method returns indeces that appear to be
> relative to the leaf's parent, which in this case doesn't help me identify
> which branch item is the selected item's parent.
>
> Thanks in advance!
> Scott
>
>
>
>
>
>
>
>
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
More information about the PyQt
mailing list