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. Alternative implementation of XmlListView

Alternative implementation of XmlListView

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

    Hi,

    I'm trying to implement an alternative to XmlListView in C++. Unfortunately, I'm quite new to programming (esp. C++), so I need some help. Essentially, what I want to achieve, is something that looks like this in QML:
    @
    XmlListModel2 {
    id: xmlModel
    source: "file.xml"
    query: "/xml/something"

         XmlConnect { name: "one";
                      query: "name/string()";
                      source2: "file2.xml";
                      query2: "/root/something/@name/string()" }
         XmlSearch { name: "oneEn";
                      query: "name/string()";
                      where: "@xml:lang";
                      is: "en" }
    

    }
    @
    The XmlConnect creates an List Role element (or whatever that's called) called "one", and basically it looks into file.xml for the string in the name attribute, matches it with the <name> content in file2.xml and returns that value (e.g. string1 or string2 in the example below).

    The XmlSearch returns the value of the string where the language is English (i.e. "John" in the example below), or if none is found, the value of the tag without any attributes (i.e. "Peter" in the example below)

    Essentially, the list created from the example below would look something like this:
    {one: "string1"; oneEn: "John"}
    {one: "string2"; oneEn: "Peter"}

    This means that for example, the XML files look like this:
    file.xml:
    @
    <xml>
    <something>
    <name>Johannes</name>
    <name xml:lang="en">John</name>
    </something>
    <something>
    <name>Peter</name>
    </something>
    </xml>
    @
    file2.xml:
    @
    <root>
    <something name="Johannes">string1</something>
    <something name="Peter">string2</something>
    </root>
    @
    I am not asking you guys to implement this for me, but I am struggling with the C++ side. Basically, I need to know what the code looks like to have this kind of a list implemented. Then, I will add the code doing the XML queries myself. Basically, I need to know how to implement these classes so that I can then use them in QML. Up until now, I can do the queries in C++, but connecting all this to the QML side is where I'm struggling. Note: I'm using a QmlApplicationViewer in main.cpp. Can you help me?
    Thank you very much.
    Keba

    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