Add read-only diff column to QSortFilterProxyModel that calculates on model data
-
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.
-
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!
-
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]
-
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.