QListWidget, get item position in list?
Solved
General and Desktop
-
Is it possible to get the index or position of an item in the list? I've looked at QListWidget and QListWidgetItem, nothing obvious...
When I get the signal currentItemChanged I get the current and previous items as parameters, what I need to do is store a reference to the position of each.
-
@SPlatten
I wrote:QListWidgetItem::listWidget()->row(item).
However, you may be safer using
QListWidgetItem::listWidget()->findItems(item->text())
, instead of relying on indexes staying the same, depending on what you are doing.How does
QListWidgetItem::listWidget()->row(item)
not answer your question, "position of an item in the list"?