SOLVED - Is myQListWidget->selectedItems().at(0)->text() always the same as myQListWidget->currentItem()->text() ?
-
Given, the mode of selection is single selection, do these both yield the same result?
myQListWidget->selectedItems().at(0)->text();
myQListWidget->currentItem()->text();
-
Hi,
AFAICT, yes. But to confirm that, writing a little test application would have got you the answer sooner
-
Thanks @SGaist! I am sorry, I wasn't able to find the official Qt repo at the time of posting this question, that's why I asked this question. Later, when I found it, I went through the code and got my answer.
The answer is:
If aQListWidgetItem
is passed tosetCurrentItem()
(directly or indirectly;setCurrentItem()
also selects the specified item, if the selection mode is notQAbstractItemView::NoSelection
), then bothmyQListWidget->selectedItems().at(0)->text()
andmyQListWidget->currentItem()->text()
show the same result. Whereas, if an item is selected by any other means, then it may or may not become the current item, hence both may yield different results. -
Why did you need the Qt repo ?