Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Insert column in a QTableView

    General and Desktop
    3
    3
    2212
    Loading More Posts
    • 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.
    • Robey Mardon
      Robey Mardon last edited by Robey Mardon

      I'm using QSqlTableModel along with QTableView and the model returns the columns and rows, for example: name, brand, how to insert a custom column between them on QTableView? For example: name, model, brand.

      Let me explain it better... only name and brand is within the database, the model is a custom column that I need to add between them, and it doesn't need to be saved on the database, because the value can alter in runtime.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You need a proxy model. Have a look a QAbstractProxyModel and QSortFilterProxyModel

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • D
          DavidFaure last edited by

          I wrote such a proxy (generic insertion of extra columns). You can use it, assuming LGPL code is OK:

          http://api.kde.org/frameworks-api/frameworks5-apidocs/kitemmodels/html/classKExtraColumnsProxyModel.html

          1 Reply Last reply Reply Quote 1
          • First post
            Last post