QListWidget - Clear currentRow value?
-
I'm using
QListWidget::clearSelection()
to clear the user's selection, but this doesn't clear thecurrentRow
value. As such, if the user clicks on the same row that was previously selected, it doesn't generate acurrentRowChanged()
signal.I need a way to clear the
currentRow
, but I can't see a method for doing so. I've tried callingsetCurrentRow()
with -1 (the default value when no row is selected) but that just causes the program to crash. I've also tried working around the problem by using theitemClicked()
signal to get a signal if the same row is re-selected, but having this signal connected seems to change the behaviour of when thecurrentRowChanged()
signal is generated.If I could just clear the
currentRow
that would solve the problem, but I can't find a way of doing so. Is there a way?Thanks a lot.
-
Since the currentRow() returns the row with the currentIndex (which has nothing to do with selection) you have to call
setCurrentIndex(QModelIndex())
-
Since the currentRow() returns the row with the currentIndex (which has nothing to do with selection) you have to call
setCurrentIndex(QModelIndex())
@Christian-Ehrlicher said in QListWidget - Clear currentRow value?:
setCurrentIndex(QModelIndex())
That solved the problem. Thanks a lot.