Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Extract data from QModelIndex

Extract data from QModelIndex

Scheduled Pinned Locked Moved Solved General and Desktop
qmodelindexqmodelindexlist
3 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • UnitScanU Offline
    UnitScanU Offline
    UnitScan
    wrote on last edited by UnitScan
    #1

    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

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      UnitScanU 1 Reply Last reply
      3
      • mrjjM mrjj

        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 ?

        UnitScanU Offline
        UnitScanU Offline
        UnitScan
        wrote on last edited by
        #3

        @mrjj yes, thank you!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved