[Interest] DelegateModel: Dynamic Delegate Model groups

Jason H jhihn at gmx.com
Tue Jul 26 17:23:19 CEST 2016


> I'd just write my proxy model in C++ and be done with it.
> 
> André
> 
> 
> Op 26/07/2016 om 15:46 schreef Jason H:
> > I want to have groups corresponding to the equivalent of 'SELECT DISTINCT x' query. Then I want each item assigned to a group of it's value of x. For example:
> > 'SELECT DISTINCT x' -> ['a', 'b', 'c']
> > 'SELECT x,y' -> [ ['a', '1'], ['a','2'], ['b','3'], ['c', '4'], ['c','11'] ]
> >
> > Then I have 3 groups: a has 2, b has 1, c as 2, then I want to set filerOnGroup to one of the groups. Is there a way to do this?

DelegateModel.groups is a list<DelegateModelGroup>, but there seems to be no way to add a group to it.
The DelegateModel.groups property resolves (in QtCreator) to an instance of a DelegateModelGroup (having .addGroup()) which applies to adding groups to *model items* and not groups it self.

When I console.log groups, I get:  {"0":{"objectName":"","count":8,"name":"items","includeByDefault":true},"1":{"objectName":"","count":0,"name":"persistedItems","includeByDefault":false}}

So I try: 
  var recipientGroup = recipientComponent.createObject(recipientComponent, {includeByDefault: false, name: number}) // (works)
  groups[groups.length] = recipientGroup; but it doesn't take.
Of I try to assign them all at once: groups = recipientModelGroups;
I get: Error: Cannot assign QList<QObject*> to QQmlListProperty<QQmlDelegateModelGroup>



More information about the Interest mailing list