How setCurrentIndex to none?
-
After deletion item in my QListView i want to set current index to NONE, it's automatically change it to next, but i want no item selected.
Tried fill it with empty index(it's all my poor imagination capable for now)
QModelIndex *noIndx = new QModelIndex(); ui->listV->setCurrentIndex(noIndx);
it rejects to compile because "want const model index, not this scum".
UPDATE:
Found:
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
But it seems working but only apart. View works like nothing selected(which already good), but visually closest item still selected.
-
After deletion item in my QListView i want to set current index to NONE, it's automatically change it to next, but i want no item selected.
Tried fill it with empty index(it's all my poor imagination capable for now)
QModelIndex *noIndx = new QModelIndex(); ui->listV->setCurrentIndex(noIndx);
it rejects to compile because "want const model index, not this scum".
UPDATE:
Found:
selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
But it seems working but only apart. View works like nothing selected(which already good), but visually closest item still selected.
it rejects to compile because "want const model index, not this scum".
void QAbstractItemView::setCurrentIndex(const QModelIndex &index)
(http://doc.qt.io/qt-5/qabstractitemview.html#setCurrentIndex)So it takes a
QModelIndex &
, not aQModelIndex *
:QModelIndex *noIndx = new QModelIndex(); ui->listV->setCurrentIndex(*noIndx);
or (simpler, no clean up):
ui->listV->setCurrentIndex(QModelIndex());