How to switch items from treewidget to another treewidhet

  • This post is deleted!

  • Qt Champions 2017

    I'm assuming that you have used QTreeWidget to create you UI.

    1. Write a slot for your command button
    2. Inside the slot, get the item selected in first treewidget. You can use the currentItem(...) API
    3. Inside the slots, create new QWidgetTreeItem & add this second Treewidget.

  • Qt Champions 2018

    I never like duplicating model data so I'll propose a different way:
    create a QSortFilterProxyModel call setFilterRole(Qt::UserRole) and setFilterFixedString("a") on it. set the source model as treeWidget->model() and assign it to the second QTreeView (not QTreeWidget given you are handling the model separately). Now all you need to do is call setData(index,'a',Qt::UserRole) for each index you want to appear on the other side

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.