Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting multiple selection in QTreeView

Tags:

qt

I have a need here regarding multiple selection of items in the QTreeView. I have two widgets, QTreeView on left and another QGLWidget on the right. If I do a multiple selection, I must highlight the items in the glwidget. Vice versa, I need to highlight the items in the tree view if multiple selection is done on the glwidget. Currently, I am able to update single item by setting the current index of the tree view. Any ideas on how to update the selection of multiple items on the tree view with multiple selection on glwidget?

like image 518
krishyy Avatar asked Feb 22 '11 08:02

krishyy


1 Answers

You can use the tree view's item selection model (treeView->selectionMode(), of type QItemSelectionModel). It has a signal selectionChanged() you can connect to to receive tree view selection changes and apply them to the GL view. When receiving selection events from the GL view, you can use QItemSelectionModel::select() to propagate them to the tree view.

To enable multiselection on your treeview, call setSelectionMode( MultiSelection ).

like image 155
Frank Osterfeld Avatar answered Sep 27 '22 18:09

Frank Osterfeld