[PyQt] QTreeWidget invisible root item
Baz Walter
bazwal at ftml.net
Mon Oct 26 18:42:28 GMT 2009
Taylor Carrasco wrote:
> The situation is - I have many "root" nodes coming from Maya, all going to
> be displayed in column 0, and their subsequent row, with a parent/child
> relationship (obviously the roots have no parent). But my question was
> related to whether I should bother with this "invisible root node",
> attaching parenting my Maya root nodes under the invis root, or if I need to
> create my own, or if I should create one like you've shown.
none of the above :)
the easiest way to create top level nodes is like this:
top_node0 = QTreeWidgetItem(mytreewidget)
or perhaps like this:
top_node1 = QTreeWidgetItem()
mytreewidget.insertTopLevelItem(1, top_node1)
whenever a top level node is inserted, the invisible root item is
automatically set as parent. but the invisible root item only really
becomes useful *after* the tree of items has been created.
the qt docs explain pretty nicely what sorts of uses it can be put to:
http://doc.trolltech.com/4.5/qtreewidget.html#invisibleRootItem
More information about the PyQt
mailing list