Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to get XML attributes default value when use XmlListModel / XmlRole.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dFrontia
    wrote on last edited by
    #1

    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:"@value/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

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dFrontia
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved