jeeie
13th March 2014, 17:23
Hi there,
I'm trying to programmatically select a number of rows in a QTreeView showing the contents of a custom QStandardItemModel.
QItemSelectionModel* selectionModel = myTreeView->selectionModel();
QItemSelection selectedItems;
selectedItems.select(topIndex, bottomIndex);
selectionModel->select(selectedItems, QItemSelectionModel::ClearAndSelect);
When the topIndex (May 01) and bottomIndex (May 02) rows have the same parent, it works well.
+ May
|-- 01 // selected
|-- 02 // selected
However, if the bottomIndex (May 02) doesn't have the same parent as the topIndex (April 30), no items are selected:
+ April
|-- ...
|-- 30
+ May
|-- 01
|-- 02
Is this a limitation of QItemSelection::select method? Or am I misusing it?
I was wondering if this should be done manually, by selecting individual ranges in each branch and merging them after.
Thank you for your answer!
Best,
j
I'm trying to programmatically select a number of rows in a QTreeView showing the contents of a custom QStandardItemModel.
QItemSelectionModel* selectionModel = myTreeView->selectionModel();
QItemSelection selectedItems;
selectedItems.select(topIndex, bottomIndex);
selectionModel->select(selectedItems, QItemSelectionModel::ClearAndSelect);
When the topIndex (May 01) and bottomIndex (May 02) rows have the same parent, it works well.
+ May
|-- 01 // selected
|-- 02 // selected
However, if the bottomIndex (May 02) doesn't have the same parent as the topIndex (April 30), no items are selected:
+ April
|-- ...
|-- 30
+ May
|-- 01
|-- 02
Is this a limitation of QItemSelection::select method? Or am I misusing it?
I was wondering if this should be done manually, by selecting individual ranges in each branch and merging them after.
Thank you for your answer!
Best,
j