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. What is the syntax to properly use a variable in a Qt Qml XmlLIstModel query
Forum Update on Monday, May 27th 2025

What is the syntax to properly use a variable in a Qt Qml XmlLIstModel query

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 662 Views
  • 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.
  • A Offline
    A Offline
    AllenB2012
    wrote on 25 Jul 2013, 17:47 last edited by
    #1

    I have the following XmlListModel defined.
    I have tested it and it returns all of the items in the xml file.
    I would like to filter it using a variable passed in to it, such as Parentpageid = my_variable.
    Can someone please show me how to do this. I want to filter this xml and return the items that match the value of my_variable.

    Thanks.

    @import QtQuick 2.0
    import QtQuick.XmlListModel 2.0

    XmlListModel {
    id: ios_elementsModel
    source: "/TestCode/PositionersAndRepeaters/PositionersAndRepeaters/menuitems.xml"
    query: "/MenuItems/MenuItem"

    XmlRole { name: "id"; query: "id/number()" }
    XmlRole { name: "type"; query: "type/string()" }
    XmlRole { name: "index"; query: "index/string()" }
    XmlRole { name: "verbage"; query: "verbage/string()" }
    XmlRole { name: "parentpageid"; query: "Parentpageid/number()" }
    XmlRole { name: "destinationpageid"; query: "destinationpageid/number()" }
    

    }@

    1 Reply Last reply
    0

    1/1

    25 Jul 2013, 17:47

    • Login

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