April 29, 2012

dFrontia dFrontia
Lab Rat
8 posts

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.

  1. model:XmlListModel{
  2.    ......
  4.   XmlRole { name:"mValue"; query:"@value/number()" }
  5.   XmlRole { name:"mOption"; query:"@option/string()" }
  6. }

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

2 replies

April 30, 2012

mbrasser mbrasser
Lab Rat
452 posts

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.


April 30, 2012

dFrontia dFrontia
Lab Rat
8 posts

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.


  ‹‹ QML - Pie menu      [SOLVED] How can I wrap QPushButton into QDeclarativeItem? ››

You must log in to post a reply. Not a member yet? Register here!