Move multiple selected items from Qtreeview to QListBox
-
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);
@ -
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.
-
Thanks a lot for the suggestion
-
Which model should I create? A QProxyModel or something..
-
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.