Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to switch items from treewidget to another treewidhet

How to switch items from treewidget to another treewidhet

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 697 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Heya
    wrote on last edited by
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      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.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      2
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

        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

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        1 Reply Last reply
        2

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved