Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
6.2.3
-
None
-
macOS 12.2
Description
After updating Qt from 5.15.0 to 6.2.3 selecting an item of a model derived from QItemSelectionModel by ::select (both overloads) seems not to select the item. isSelected and hasSelection, both return false.
Probably related to https://bugreports.qt.io/browse/QTBUG-93301
Minimal example to reproduce:
void BrandPluginViewModel::sayHello() { qDebug() << "Hello! "; } void BrandPluginViewModel::init() { // Create selection test model to check if ::select works properly QItemSelectionModel* selectionModel = new QItemSelectionModel(m_sourceModel); // m_sourceModel is derived from QAbstractListModel; rowCount is 8 in my case QModelIndex modelIndex = m_sourceModel->index(1, 0); selectionModel->select(modelIndex, QItemSelectionModel::Select); connect(selectionModel, &QItemSelectionModel::selectionChanged, this, &BrandPluginViewModel::sayHello); qDebug() << "selectionModel->hasSelection = " << selectionModel->hasSelection(); // prints false qDebug() << "selectionModel->isSelected = " << selectionModel->isSelected(modelIndex); // prints false }