Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.12.3
-
None
-
Windows 10, Qt 5.12.3, Microsoft Visual Studio Community 2022
Description
QColumnView selection is not working properly when trying to select an index using the QItemSelectionModel::setCurrentIndex(), QItemSelectionModel::select() or any other method used for selection.
I have implemented a Qt application which shows a hierarchy. I use QColumnview and I set a custom model to it to build the hierarchy. When I do the selection manually (click on an item in qcolumnview) it works fine.
The issue: I have my own method in which I look for the index in the model and then try to select it in the QColumnView using the above setCurrentIndex() or select() methods. In some cases the parent levels are not selected in columnView.
In the attached screenshot I used the following line:
columnView->selectionModel()->setCurrentIndex(userIndex, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
to select the "User" index in the QColumnView and the first level is not selected.
I checked the selected indexes using the method:
columnView->selectionModel()->selectedIndexes()
and it gives the correct number of selected indexes. So the problem might be that the index is selected but is not highlighted.