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. Adding columns to a proxy model without affecting the source model

Adding columns to a proxy model without affecting the source model

Scheduled Pinned Locked Moved Solved General and Desktop
qsqltablemodelproxy
3 Posts 2 Posters 1.9k 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.
  • M Offline
    M Offline
    mjsurette
    wrote on 17 Aug 2016, 17:28 last edited by
    #1

    I have a QSqlTableModel being shown in a QTableView with a QSortFilterProxyModel derived class between them.

    I want my view to display a calculated column, so I add this column to the proxy model and have the data() function calculate the value. Unfortunately inserting a column to the proxy model also adds the new column to my QSqlTableModel. This throws the updates of my QSqlTableModel askew.

    Is there an existing model which will allow me to add a column to it while leaving the source model alone or is this something I have to craft? If I have to create this, is there a place to post such things for others to use?

    Mike

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 17 Aug 2016, 17:41 last edited by
      #2

      The KDE API (works on every platform supported by Qt) has what you need KExtraColumnsProxyModel

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mjsurette
        wrote on 17 Aug 2016, 17:56 last edited by
        #3

        Awesome! Thank you @VRonin .

        1 Reply Last reply
        0

        3/3

        17 Aug 2016, 17:56

        • Login

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