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. Move multiple selected items from Qtreeview to QListBox
QtWS25 Last Chance

Move multiple selected items from Qtreeview to QListBox

Scheduled Pinned Locked Moved General and Desktop
6 Posts 2 Posters 2.4k 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.
  • S Offline
    S Offline
    sargeslash
    wrote on last edited by
    #1

    I want to move selected items from QTreeview (populated by QFileSystemModel) to a QListBox. I have managed to get all selected items in a QMdelIndex list, but I cant add this to QListbox since QListBox->addItems(QStringList) only accepts QStringList.
    Please guide me through.

    @QItemSelectionModel selectiveModel=ui->treeView->selectionModel();
    QModelIndexList list=selectiveModel.selectedIndexes();
    ui->inputImageLstBox->addItems(list);
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You can't. Not directly. An item in one view is not a separate object that you can just stick in another view.

      You'll have to add what the other view represents, or build some kind of proxy that represents the selected items from one view as a new model, that you can set on your list view.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sargeslash
        wrote on last edited by
        #3

        Thanks a lot for the suggestion

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sargeslash
          wrote on last edited by
          #4

          Which model should I create? A QProxyModel or something..

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            It depends on the kind of interaction you're really after. You're not giving us enough information on what you want to do exactly. Also, I guess it depends on your level of Qt knowledge and C++ proficiency as well.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sargeslash
              wrote on last edited by
              #6

              I am sorry for less info, I want to add multiple selected items from a QTreeView to a QListBox, as right now I am abe to add one selected item from the QTreeView to QListBox.I am adding the item by double clicking on the item in the QTreeView.
              I am not an expert in c++ nor in Qt.

              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