Qt Forum

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

    Call for Presentations - Qt World Summit

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

    QML and Qt Quick
    1
    1
    520
    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.
    • A
      AllenB2012 last edited by

      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 Reply Quote 0
      • First post
        Last post