QListView : how to set selection after reset
-
I've created a QListView, with a QStringListModel. If I call
model->setStringList()
, the model & the selectionModel are being reset, thus there is no valid selection anymore. I'd like to select the first item in such case, but overwritingQListView::reset()
with [1] didn't do anything. Any help?[1]
void PatchedListView::reset() { QListView::reset(); selectionModel()->setCurrenIndex(model()->index(0,0), QItemSelectionModel::SelectCurrent); // debugging shows the index is valid & as expected, the second time this breakpoint is hit }
-
Hi and welcome to devnet,
What about using setCurrentIndex ?