QModelIndexList indexList = myModel->match( myModel->index(0, 0), Qt::DisplayRole, QVariant(value), -1, Qt::MatchRecursive ); foreach(QModelIndex index, indexList) { // access data at each index qDebug() << index.data(Qt::DisplayRole).toString(); }
QModelIndexList indexList = myModel->findItems(value, Qt::MatchRecursive); indexList.clear();
QModelIndexList indexList = myModel->match( myModel->index(0, 0), Qt::DisplayRole, QVariant(value), -1, Qt::MatchRecursive ); foreach(QModelIndex index, indexList) { int row = index.row(); int column = index.column(); qDebug() << "row:" << row << "column:" << column; }This code shows how to get the row and column of a QModelIndex object using the row() and column() functions. In this example, the code loops through all the QModelIndex objects in the indexList and prints their row and column values. Package/library: Qt