XMLListModel Related Questions

  • Hello

    A while ago i needed to create a program which uses xml files. But i have never worked with neither xml nor json files. So i don't have much of an idea about them, which is why i decided to download a few xml files from the internet and work with them.

    Anyways here are my questions regarding xml files

    1. I tried loading which was very succesfull, but i couldn't read a single value from it although playing around with it for while. How can i read the values and display them on screen.

    2. Is it possible to write values after they are changed by the user?

    3. Can i group these together with, like one-key-one-value. So i can have them better controlled?

    Thanks in advance for any help.

    Here is my code and xml file:

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import QtQuick.XmlListModel 2.0
    Window {
        visible: true
        width: 1200
        height: 600
        title: qsTr("Hello World")
        MainForm {
            anchors.fill: parent
            color: "#141414"
            ListView {
                spacing: 5
                model: xmlModPlist
                delegate: Text {
                    color: "#ffffff"
                    text: key
                    font.family: "Calibri"
                    font.pointSize: 16
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
                    antialiasing: true
            XmlListModel {
                id: xmlModPlist
                source: "qrc:/Res/particle.plist"
                query: "/plist/dic"
                XmlRole {name: "key"; query: "key/string()"}
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">

  • Okay, so i learned a few things.

    It seems writing to xml files using QML is not possible, but by using C++ side of things it can be done. So my questions are now invalid it seems.

Log in to reply