PDA

View Full Version : Filter in QTableView



ro12man3
23rd March 2016, 20:54
My QTableView has this structure:
Number, Month, Code.
Numbers are in first column, months in second, codes in third.

On example my tableview will looks so:
200, 02, 23
10, 02, 23
30, 03, 24

How can I do that function:
if values in second and third column values are the same, then make one line(is it correct term?) with that values, and in the first column program must to show the sum of all values of first columns.

So, the result must be:
210, 02, 23
30, 03, 24

How to do that? I really need help.

wysota
23rd March 2016, 22:22
One way is to create a proxy model that will aggregate the values. Another is to have a separate model that will keep the aggregated data and will recalculate itself when the base model changes.

anda_skoa
23rd March 2016, 22:23
What are you using as your model?

Cheers,
_

ro12man3
23rd March 2016, 22:36
I do that with my model

QSqlQueryModel * model = new QSqlQueryModel(0);
model->setQuery("select ......");

wysota
24th March 2016, 14:49
Then why don't you aggregate the data using a "group by" clause in your query?