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. Using booleans in XmlModelList

Using booleans in XmlModelList

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 674 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.
  • R Offline
    R Offline
    Rolias
    wrote on last edited by
    #1

    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
    0

    • Login

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