[SOLVED] Qt5.2 How to expand all child items in Qtreewidget?
-
Hi, I have the following code:
@void MainWindow::AddRoot (QString name)
{
QTreeWidgetItem *itm = new QTreeWidgetItem(ui->treeWidget);
itm->setText(0,name);AddChild(itm, tr("Name")); AddChild(itm, tr("Address")); AddChild(itm, tr("Tel"));
}
void MainWindow::AddChild (QTreeWidgetItem *parent, QString name)
{
QTreeWidgetItem *itm = new QTreeWidgetItem();
itm->setText(0,name);
parent->addChild(itm);} @
How do i make the child items under the parent level expand/collapse by default on run time?
qxoz: for future, please add code tags for code
-
Have you try "setExpanded":http://qt-project.org/doc/qt-5/qtreewidgetitem.html#setExpanded ?
-
yes I looked into it but I'm not quite sure how to use it. do you have an example code? thx
-
Thanks @qxoz ! it works!