Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to read data from QTableView?



  • 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.....



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



  • Just iterate over the model in any order you like?



  • 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().


Log in to reply