Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Using booleans in XmlModelList

    QML and Qt Quick
    1
    1
    504
    Loading More Posts
    • 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.
    • R
      Rolias last edited by

      I'm experimenting with the XmlModelList and I can get string() and number() data to behave but not booleans. According to the Qt Assitant docs on XmlRole if your data has an attribute like wanted="true" Then you use
      @@XmlRole { name: "wanted"; query: "boolean(@wanted)" }@

      The problem is that this always returns true for wanted even if it's wanted="false" or wanted="0" in the XML data. If the attribute is missing entirely then it returns false. Here's a snippet of my actual test XML data
      @ <clip href="qt-quick--m07-c01.wmv" title="Overview" awesome="false"/>
      <clip href="qt-quick--m07-c02.wmv" title="Transforms" awesome="0" />
      <clip href="qt-quick--m07-c03.wmv" title="Demo: Transforms" awesome="junk"/>
      <clip href="qt-quick--m07-c04.wmv" title="Animation" awesome="true"/>
      <clip href="qt-quick--m07-c05.wmv" title="Easings"/>@

      The XmlRole is defined as:
      @XmlRole{name: "awesome" ; query:"boolean(@awesome)"}@

      The ListView delegate is:
      @delegate : Text {text :title
      font.bold : awesome
      wrapMode: Text.WordWrap
      width:200}@

      The first four titles show up in bold. The fifth item does not.

      Again I'm just trying to increase my understanding. I can think of workarounds I would just like to understand how booleans are supposed to be used.

      Check out my third course in the trilogy on Qt
      "Integrating Qt Quick with C++"
      http://bit.ly/qtquickcpp
      published by Pluralsight

      1 Reply Last reply Reply Quote 0
      • First post
        Last post