Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

qt

I have to call expandAll() in the constructor, but that looks unnecessary,

enter image description here

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?

like image 286
daisy Avatar asked Oct 31 '12 07:10

daisy


1 Answers

You can write your own function to add items and then use it to fill the tree:

void addRootNode(const QString& value) {
    QTreeWidgetItem* treeItem = new QTreeWidgetItem();
    treeItem->setText(value);
    ui->treeWidget->addTopLevelItem(treeItem);
    ui->treeWidget->expandItem(treeItem);
}
like image 197
Artem Zh. Avatar answered Oct 10 '22 23:10

Artem Zh.