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. How to read data from QTableView?

How to read data from QTableView?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 5.9k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    mady
    wrote on last edited by
    #1

    I googled but did not get anything related to what I am looking for.
    I have created a table using QStandardModelItem/QTableView but I am not sure how to read the data from the table. I am able to read the header using QStandardModelItem::headerData() but not able to read the table contains. Let me know if there is any better ways to do that.

    Thanks in advance.....

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mady
      wrote on last edited by
      #2

      Basically I am looking for something to read the table column wise.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        Just iterate over the model in any order you like?

        1 Reply Last reply
        0
        • B Offline
          B Offline
          broadpeak
          wrote on last edited by
          #4

          Reading data:
          @
          item(row, YourColumnNameAsConstansString)->text()
          @
          or a similar:
          @
          static_cast<quint16>(item(row, YourColumnNameAsUInt16)->data(Qt::EditRole).toUInt())
          @
          item is a QStandardItem.

          In QStandardItemModel you can retrieve the index or item with these: itemFromIndex() and indexFromItem().

          1 Reply Last reply
          0

          • Login

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