List View using two elements
-
wrote on 21 Jun 2011, 15:03 last edited by
Could you explain more ? I didn't understand what you want.
Why is it impossible to get all data and after send them to the listModel ? -
wrote on 22 Jun 2011, 01:28 last edited by
oops, i missed some details..
i used the setContextProperty, this is the code: @view->engine()->rootContext()->setContextProperty("memberSelectionCpp",selectLevel);
@
And the seen member of team 1 is "undefined"the fungsiReturnID is as follows:
@QString memberSelect::fungsiReturnID(int index)
{
return soapResult.result->__ptr[index]->UserID;
}
@
i used a gsoap to return ID from my dummy database
it is possible to display the data if i inputted it manually, but just in case if my data got increasing, then it would get even harder to input them all manually, right? Any suggestion to fix it? Thanks. -
wrote on 22 Jun 2011, 03:05 last edited by
I tried this and got a run time error that script can not be used to specify ListElement property value. Can "TROLLS" help here?
@chronoske, are you getting any qml run-time error?
-
wrote on 22 Jun 2011, 03:30 last edited by
nope, i didn't get any run-time error at all, the return string just doesn't show. that's all..
-
wrote on 22 Jun 2011, 04:10 last edited by
@ ListElement { ListElement.objectName: memberSelectionCpp.fungsiReturnID(2); team: 1 }@
I did not get whey are you using ListElement.objectname here?? where did you get this from?
Should't it be something like
@ListElement { name: memberSelectionCpp.fungsiReturnID(2); team: 1 }@may be I am wrong...
-
wrote on 22 Jun 2011, 05:26 last edited by
i tried using that trick as well, but instead it gives a warning "ListElement: cannot use script for property value
ListElement { name: memberSelectionCpp.fungsiReturnID(2) ; team: 1 }"And when i try to type ListElement, the autocomplete shows only two options: deleteLater or objectName, so i picked the objectName, and the result is undefined. Could it be that i used the wrong syntax?
-
wrote on 22 Jun 2011, 05:35 last edited by
I think, with ListElement.objectName, you are trying to assign value to "objectName" property of the ListElement.
For back-ground about objectname, http://doc.qt.nokia.com/latest/qobject.html#objectName-prop
-
wrote on 1 Jul 2011, 10:11 last edited by
i'm sorry, but could anyone explain more? My problem is that i can not insert strings that is being returned by a function in cpp into list view element. I have tried to look for sample codes but all that i found is the list view name that is inputted manually, and since i have quite some data, i don't think that it will be possible,, Help, anyone?
thank you
-
wrote on 1 Jul 2011, 10:38 last edited by
Looks like some good news for you.. You can do it..
@ListModel {
id: myModel
ListElement { name: "Bob"; team: 2 }
ListElement { name: "Jane"; team: 3 }Component.onCompleted: { append({name:memberSelectionCpp.fungsiReturnID(2),team:1}) } }
@
If you want to insert your element in a different place, you can use insert function of ListModel.
But you need to make sure something from C++ side..
Make sure that "memberSelectionCpp" is made available to qml with setContextProperty before you set your qml file to QDeclarativeView. Otherwise above code does not work. Try and let us know if this works.
-
wrote on 13 Jul 2011, 01:34 last edited by
I still can't figured it how, so I guess I'll try to change the concept for my project. Thanks everyone!
-
wrote on 13 Jul 2011, 03:30 last edited by
[quote author="chronoske" date="1310520896"]I still can't figured it how, so I guess I'll try to change the concept for my project. Thanks everyone![/quote]
It seems to work for me. What is the problem you are facing..