QTreeWidget: How to display the root item?
Hello.
I'm building a Qt application with a QTreeWidget. I've got several TopLevelItems each with some childs. But all the Items are "hanging" on the top end of the QTreeWidget like this:
Code:
|
[-]TopLevelItem1
| |
| -Child1
| |
| -Child2
|
[-]TopLevelItem2
|
-Child3
I read in the documentation that there is a "invisibleRootItem", but I got no success to make it visible.
How can I display the root item?
I wanted to have a tree like this:
Code:
RootItem
|
[-]TopLevelItem1
| |
| -Child1
| |
| -Child2
|
[-]TopLevelItem2
|
-Child3
Re: QTreeWidget: How to display the root item?
You don't want to make it visible. You want to set rootIsDecorated property to false.
Re: QTreeWidget: How to display the root item?
My primary intention was to display the root item, but your suggestion to try the property rootIsDecorated lead also to a good looking result.
I tried it and now my topLevelItems are childs and my new topLevelItem looks like a root item. Thanks! :)
Re: QTreeWidget: How to display the root item?
You can't display the invisibleRootItem because it is a fake item used only to have an equivalent of empty QModelIndex.
Re: QTreeWidget: How to display the root item?
That's a good reason. Thanks for the explanation.