Perfect.  Thanks!
Scott





On Aug 27, 2009, at 9:29 AM, Jamie Riotto wrote:

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<[email protected]> 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    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Scott Frankel
President/VFX Supervisor
Circle-S Studios

www.circlesfx.com
510-339-7477 (o)
510-332-2990 (c)








_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to