[PyQt] QTreeWidget invisible root item

Baz Walter bazwal at ftml.net
Sat Oct 24 14:48:45 BST 2009


Taylor Carrasco wrote:
> How do you add an invisible root item?

by definition, there can only be one root item and that is already 
provided by the treewidget.

something like this might do what you want:

myroot = QTreeWidgetItem(mytreewidget)
mytreewidget.setRootIndex(mytreewidget.indexFromItem(myroot))

but note that that wont actually replace the invisible root item - it 
just creates a hidden top level item that can be used as the parent of 
all subsequent items.

(as usual, it would be a lot easier to help if you told us what problem 
you are actually trying to solve...)


More information about the PyQt mailing list