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.
  • U Offline
    U Offline
    UnitScan
    wrote on 7 Feb 2018, 13:58 last edited by UnitScan 2 Jul 2018, 14:02
    #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
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 7 Feb 2018, 14:09 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 ?

      U 1 Reply Last reply 7 Feb 2018, 14:17
      3
      • M mrjj
        7 Feb 2018, 14:09

        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 ?

        U Offline
        U Offline
        UnitScan
        wrote on 7 Feb 2018, 14:17 last edited by
        #3

        @mrjj yes, thank you!

        1 Reply Last reply
        1

        1/3

        7 Feb 2018, 13:58

        • Login

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