Extract data from QModelIndex
Solved
General and Desktop
-
I created a QTableWidget, and now I would like extract the indexes (so, can be more than one) of the currently selected rows, so I can process them later. From my attempt, where tracklist is my QTablwWidget
QItemSelectionModel *select = tracklist->selectionModel(); QModelIndexList phi = select->selectedRows(); QList<QModelIndex>::iterator x; for (x = phi.begin(); x != phi.end(); ++x) { qDebug() << *x ; }
The output is:
QModelIndex(0,0,0x0,QTableModel(0x2031bb98)) QModelIndex(1,0,0x0,QTableModel(0x2031bb98)) QModelIndex(2,0,0x0,QTableModel(0x2031bb98)) QModelIndex(3,0,0x0,QTableModel(0x2031bb98)) QModelIndex(4,0,0x0,QTableModel(0x2031bb98)) QModelIndex(5,0,0x0,QTableModel(0x2031bb98))
What interests me, is the first term between the round brackets (0,1,2,3,4,5). There is a way to extract this value?
Thank you in advance
-
Hi
Is that not just
http://doc.qt.io/qt-5/qmodelindex.html#row
http://doc.qt.io/qt-5/qmodelindex.html#column
of the QModelIndex ?