How can I make the items in QTreeWidget expanded by default?

qt

Solution

You can use

setExpanded(true);

for the parent(s) of

QTreeWidgetItem

For example:

QTreeWidget *treewidget = new QTreeWidget(this);
QTreeWidgetItem *tools = new QTreeWidgetItem(treewidget);
tools->setExpanded(true);

Problem

I have to call expandAll() in the constructor, but that looks unnecessary, The stuff I've added in form editor was just collapsed, and I failed to find an property in the right box, how should I make it all expanded by default?

Original source