[PyQt] QTreeWidget and item parents

Scott Frankel frankel at circlesfx.com
Thu Aug 27 16:46:18 BST 2009


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!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: treeTest.py
Type: text/x-python-script
Size: 3305 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090827/0a4c7206/treeTest.bin
-------------- next part --------------

More information about the PyQt mailing list