Thanks Bea,

I figured that could be done, but then I need to list every possible role. 
I'd much rather send the parameter list as a whole to the function and let that 
look for the variables it is coded for.
The function the param list being passed to supplied by a component. I'm trying 
to do this in one request, not two, but I could split it and have a model 
specific for each component. But I'd rather not do that. 

Perhaps there is a way to define the XmlRole for ParamList to be passed as a 
model itself to a function, then I can take ParamList as a model itself?







----- Original Message ----
From: "[email protected]" <[email protected]>
To: [email protected]
Cc: [email protected]
Sent: Tue, April 12, 2011 10:24:33 PM
Subject: Re: [Qt-qml] Parsing model Roles in functions

Hi Jason,

On 13/04/2011, at 10:21 AM, ext Jason H wrote:

> I have:
> XmlListModel{ 
>   id: instanceModel
>   source: "getNextInstanceXml.php"
>   XmlRole{name:"paramList";query:"instance/paramList"}
> }
> 
> Where paramList looks like:
> <paramList>
> <param name="gradientStart" value="#000000"/>
> <param name="gradientStop" value="#FFFFFF"/>
> </paramList>


The gradientStart and gradientStop values won't be placed into the model unless 
XmlRole objects are specified for them, since the model won't know the 
structure 
of the data that is supposed to be retrieved.

I'd suggest something like this, which creates an XmlRole for each value:

    XmlListModel{ 
        id: instanceModel
        source: "getNextInstanceXml.php"
        query: "/paramList"
        XmlRole { name:"gradientStart"; query:"param[1]/@value/string()" }
        XmlRole { name:"gradientStop"; query:"param[2]/@value/string()" }
    }

Now if you examine instanceModel.get(0) it will look like:

{ "gradientStart": "#000000", "gradientStop": "#FFFFFF" }


regards,

Bea


      
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to