[SOLVED] QTreeView subitem not being added correctly
-
Hi,
I'm trying to add a subitem to the selected QTreeWidget item using the following code:QTreeWidgetItem *itm = new QTreeWidgetItem(this->ui->Defs_tree); itm->setText(0, name); if (subitem) { QList<QTreeWidgetItem *> lst = this->ui->Defs_tree->selectedItems(); if ( lst.count() == 1 ) lst.at(0)->addChild(itm); }
But, the subitem gets added outside the selected item: and I'm still unable to solve the issue.
I need some help.
Thanks. -
The first line of your code puts the item into the tree already. Remove the tree parameter and you should be good to go. Be careful of leaking that item though, as you only seem to insert it conditionally.
-
@Chris-Kawa Yes, I missed that. Thanks a lot for your help.