How to get index of listWidget item found by its "text/value"
-
Hi to all,
I have a listWidget, where I can drag and reorder a list of colors(red, green, blue ...).
I would like to get the "index" aka actual positionby searching for the color name.
I already find the element, but I can't get its index.How can I do this?
Pseudo code: for (unsigned int i = 0; i < ColoList.size; i++) { qDebug() << "List: " <<ColoList[i].name; QList<QListWidgetItem*> items = ui->listWidget->findItems(ColoList[i].name, Qt::MatchExactly); index = item[0].???? }
thx in advance
-
QListWidget::row() or QListWidget::indexFromItem() then access the row().
BTW: the list of matches can be empty.