How to get XML attributes default value when use XmlListModel / XmlRole.



  • Hi,I am try QML.

    I have XML file .
    <node value="1" />
    <node value="2" option="x" />
    <node value="3" />

    ListView use, the XML file.
    @
    model:XmlListModel{
    ......

    XmlRole { name:"mValue"; query:"[object Object]/number()" }
    XmlRole { name:"mOption"; query:"@option/string()" }
    }
    @

    I got Error....
    ReferenceError: Can't find variable: mOption

    I guess, anywhere have not default value of option attribute.

    do you have same idea?

    [edit] added code wrappings, koahnig



  • Can you show the bit of code producing the error? Note that the roles will only be available within a ListView delegate, so referencing them elsewhere might produce the type of error you are seeing.

    Regards,
    Michael



  • Thinks for quick reply, Michael.

    I noticed that the spelling is wrong When i check again,today.

    and, XML Attributes is undefined, i confirmed the operation defaults to 0.

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.