Question

I have a QStandardItemModel of items where each row corresponds to a single object and each column corresponds to a property of that object. Here's an example using a student ID roster:

ID      Gender      Grade   GPA
5       Male        12      3.8
4       Female      11      3.9
8       Female      12      3.5
19      Male        9       2.1

My end goal is to let the user select one of the column names from a drop-down and have a second table display an aggregate of the values. For example, if the user selected Grade from the list, the second table would display the average GPA for each grade as follows:

ID      Gender      Grade   GPA
                    12      3.65
                    11      3.9
                    9       2.1

Or similarly by Gender:

ID      Gender      Grade   GPA
        Male                2.95
        Female              3.70

Is there anything in Qt that performs that functionality? QSortFilterProxyModel seems to come close in terms of functionality, but as far as I can tell it only culls and sorts items, not summarizes them.

Was it helpful?

Solution

Well, since no one answered this question, I consider the answer to be "No." Therefore, I subclassed QAbstractProxyModel and implemented my own AggregateProxyModel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top