Just to make sure the concat really generate the JS array, try the following (It should not give any difference, but just to make sure):
function adaptQList(src) { var rv = []; for(var i = 0; i < src.length; ++i) rv.push(src[i]); return rv; } But I suspect you have a type mismatch here, since you have a QList<QObject*> and a QQmlLisProperty<QQmlDelegateModelGroup>, try with a property of type QQmlLisProperty<QObject> and affect the value to see if this work (it should). If this work you will need to convert type of have a setter that take QQmlLisProperty<QObject> and do the C++ type check/conversion to your strongly typed QQmlDelegateModelGroup. Jerome On Tue, Jul 26, 2016 at 1:33 PM, Jason H <jh...@gmx.com> wrote: > > Thanks for the pointer, but when I hacked it in as a p.o.c: > > groups = [].concat(recipientModelGroups); //Error: Cannot assign > QList<QObject*> to QQmlListProperty<QQmlDelegateModelGroup> > > (groups is a DelegateModel.group property, recipentModelGroups is a js > array of DelegateModelGroups). I think I'm trying to go the other way? Or > the QQmlListProperty<QQmlDelegateModelGroup> is too tightly typed? > > > *Sent:* Tuesday, July 26, 2016 at 11:49 AM > *From:* "Jérôme Godbout" <jer...@bodycad.com> > *To:* "Jason H" <jh...@gmx.com> > *Cc:* "André Somers" <an...@familiesomers.nl>, "Interests Qt" < > interest@qt-project.org> > *Subject:* Re: [Interest] DelegateModel: Dynamic Delegate Model groups > QQmlListProperty<> cannot be assign with another QQmlListProperty<> or a > QList<>, but it does support javascript Array. I myself made a simple > function to convert: > > function adaptQQLP(list_obj) > { > return [].concat(list_obj); > } > It does iterate on it and create a javascript array which is enough > > MyQmlObj > { > myQQmlListProperty: adaptQQLP(myOtherId_.itsOwnQQmlListProperty) > } > > This is a workaround the QQmlListProperty madness. This and the clear and > push everything back for any modification where performance goes down the > toilette. Tumb rules avoid those QQmlListProperty as much as possible > your software performance will thank you. > > Jerome > > On Tue, Jul 26, 2016 at 11:23 AM, Jason H <jh...@gmx.com> wrote: >> >> > 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> >> _______________________________________________ >> Interest mailing list >> Interest@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/interest >> >
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest