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. Add read-only diff column to QSortFilterProxyModel that calculates on model data
Forum Updated to NodeBB v4.3 + New Features

Add read-only diff column to QSortFilterProxyModel that calculates on model data

Scheduled Pinned Locked Moved General and Desktop
25 Posts 4 Posters 12.7k 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.
  • S Offline
    S Offline
    swivelhead
    wrote on last edited by
    #21

    Just tried this on an install of Qt libs version 4.7.2 built on a Windows XP Pro x64 box at work.

    I got the same results when I ran my code using the subclass of the QSortFilterProxyModel which sources a populated QSqlTableModel.

    The difference column (read-only) appears with the correct amount in it at first. After an edit to the view, it disappears.

    So Qt libs 4.7.2 didn't fix my issue.

    Upon further inspection, the bug mentioned above does not specify a proxy model being used, just the QSqlTableModel and its call to QSqlQueryModel.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      swivelhead
      wrote on last edited by
      #22

      I wizened up and cut and paste octal's latest demo subclass of QSqlTableModel into my own, changed the number of columns, got rid of the proxy model and it worked!

      I would like to know how to get the proxy model to add the column, but my original problem is solved. Now, I can continue with the app.

      Thanks for the help, octal and Andre!

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tombalak
        wrote on last edited by
        #23

        Hi jetimms,

        Could you send the code snippet which use QSortFilterProxyModel subclassing to add the custom column addition.
        I can't realize the index problem that octal mentioned.

        Thanks,
        ugur

        [quote author="jetimms" date="1315884755"]@Andre, thanks for the tip!

        I've almost gotten it to work using the proxy model.

        The weird thing is, that the new column shows and displays the correct field name and value (the difference,) but after I update one of the values in the table the difference column disappears.

        Any ideas? It removes the column if I use either QSortFilterProxyModel or my subclass.

        Thanks.[/quote]

        1 Reply Last reply
        0
        • S Offline
          S Offline
          swivelhead
          wrote on last edited by
          #24

          @tombalak,

          I ended up basing my solution (almost exactly) from octal's code that subclassed QSqlTableModel after getting his to work in a sample. When I used QSortFilterProxyModel to subclass, any created columns would disappear after changing and submitting the values of one of them. I'm not sure that my issue was with the indexes either.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tombalak
            wrote on last edited by
            #25

            thanks jetimms,
            ugur

            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