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. Is it possible to set multiple items selcted in QTreeWidget?
Forum Updated to NodeBB v4.3 + New Features

Is it possible to set multiple items selcted in QTreeWidget?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.4k Views 1 Watching
  • 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.
  • V Offline
    V Offline
    Violet Giraffe
    wrote on last edited by
    #1

    setCurrentItem only sets one item selected. I don't see any method to set more than 1 item selected programmatically, but maybe I'm overlooking something?

    Of course, my tree widget is configured to enable multiple selection.

    Note that I'm using QTreeWidget, not QTreeView.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on last edited by
      #2

      Yes, of course it is.

      Make a new "QItemSelectionModel":http://qt-project.org/doc/qt-5.0/qtcore/qitemselectionmodel.html, call select() and set to "QTreeWidget::setSelectionModel":http://qt-project.org/doc/qt-5.0/qtwidgets/qtreewidget.html#setSelectionModel

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        You can use the "item selection model":http://qt-project.org/doc/qt-4.8/qitemselectionmodel.html of the QTreeWidget for that

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • V Offline
          V Offline
          Violet Giraffe
          wrote on last edited by
          #4

          Thanks a lot! Shame I overlooked it.

          1 Reply Last reply
          0

          • Login

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