How to switch items from treewidget to another treewidhet
Unsolved
General and Desktop
-
I'm assuming that you have used QTreeWidget to create you UI.
- Write a slot for your command button
- Inside the slot, get the item selected in first treewidget. You can use the currentItem(...) API
- Inside the slots, create new QWidgetTreeItem & add this second Treewidget.
-
I never like duplicating model data so I'll propose a different way:
create aQSortFilterProxyModel
callsetFilterRole(Qt::UserRole)
andsetFilterFixedString("a")
on it. set the source model astreeWidget->model()
and assign it to the second QTreeView (not QTreeWidget given you are handling the model separately). Now all you need to do is callsetData(index,'a',Qt::UserRole)
for each index you want to appear on the other side