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. Have you met a load problem of XmlListModel in an embedded platform
Forum Updated to NodeBB v4.3 + New Features

Have you met a load problem of XmlListModel in an embedded platform

Scheduled Pinned Locked Moved QML and Qt Quick
15 Posts 2 Posters 6.7k 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.
  • C Offline
    C Offline
    cokefish
    wrote on last edited by
    #1

    I met a problem of this.

    I use Qt 4.7.4 for both desktop and Qtembedded platform development,
    When I use a XmlListModel to load some xml file in local directory,
    then the difference occurred.

    • On desktop, the xml file load instantly and correctly as what the file is.
    • On Qtembedded platform, the XmlListModel seems never loaded,
      It kept loading without stop and the status property of XmlListModel object was held to be a constant 2, regardless of I was using relative path or absolute path of the xml file

    I looked for Qt assistant
    it is said that in QML XmlListModel Element
    #----------------
    read-only status : enumeration
    Specifies the model loading status, which can be one of the following:

    XmlListModel.Null - No XML data has been set for this model.
    XmlListModel.Ready - The XML data has been loaded into the model.
    XmlListModel.Loading - The model is in the process of reading and loading XML data.
    XmlListModel.Error - An error occurred while the model was loading. See errorString() for details about the error.
    #----------------

    For that the xml file has never been load successfully, that I think the constant "2" must be the third value *XmlListModel.Loading *.
    I should rather ask why this happened.
    Is there some difference between the qmlapplicationviewer betwenn the desktop and the Qtembedded platform?

    Thank you.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cokefish
      wrote on last edited by
      #2

      What in my understanding the xml file should be automatically loaded when the qml file using the XmlListModel executed.

      If my understanding is correct?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        deimos
        wrote on last edited by
        #3

        bq. If my understanding is correct?

        yes, thats correct. Maybe you have malformed the XmlListModel parameters. Can you provide that code for testing ?

        1 Reply Last reply
        0
        • C Offline
          C Offline
          cokefish
          wrote on last edited by
          #4

          I put my xml and qml file both in qml/myapp/myfunc folder

          and then content of the source code are

          • qml/myapp/myfunc/xmldata.xml
            @<?xml version="1.0" encoding="utf-8"?>
            <List>
            <Line type="Kind" index="0">
            <title>Kind 1</title>
            </Line>
            <Line type="Item" index="1">
            <title>Item one</title>
            <id>id0001</id>
            <comment>Item one comment</comment>
            <times>1</times>
            <rank>red</rank>
            </Line>
            <Line type="Item" index="2">
            <title>Item two</title>
            <id>id0002</id>
            <comment>Item two comment</comment>
            <times>1</times>
            <rank>red</rank>
            </Line>
            <Line type="Item" index="3">
            <title>Item three</title>
            <id>id0003</id>
            <comment>Item three comment</comment>
            <times>2</times>
            <rank>gray</rank>
            </Line>
            </List>@

          • qml/myapp/myfunc/xmldata.qml
            @// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
            import QtQuick 1.1

          Rectangle {
          id: root
          width: 480
          height: 800

          XmlListModel {
              id: xmlModel
              source: "xmldata.xml"      
              query: "/List/Line"
          
              XmlRole { name: "type";     query: "@type/string()" }
              XmlRole { name: "index";     query: "@index/string()" }
          
              XmlRole { name: "title";    query: "title/string()" }
          
              XmlRole { name: "id";       query: "id/string()" }
              XmlRole { name: "comment";  query: "comment/string()" }
              XmlRole { name: "times";    query: "times/string()" }
              XmlRole { name: "rank";     query: "rank/string()" }
          }
          

          ...
          function do_xmldata_work()
          {
          console.log("do_xmldata_work begin>: ")
          while(xmlModel.status != XmlListModel.Ready)
          console.log("loading xml file: " + xmlModel.status)
          console.log("loading xml file: " + xmlModel.status + " || finished")

              ...
          }
          

          }
          @

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cokefish
            wrote on last edited by
            #5

            I want to call the do_xmldata_work() function from some other qml file.
            When I do this:

            • On desktop
              it will output as follows:

            bq. do_xmldata_work begin>:
            loading xml file: 1 || finished

            • on Qtembedded platform
              it will output:

            bq. do_xmldata_work begin>:
            loading xml file: 2
            loading xml file: 2
            loading xml file: 2
            loading xml file: 2
            loading xml file: 2
            loading xml file: 2
            loading xml file: 2
            ...

            1 Reply Last reply
            0
            • D Offline
              D Offline
              deimos
              wrote on last edited by
              #6

              I can't tell whats going wrong :( . The xml file seems to be found by XmlListModel, but my suspicion goes to the function do_xmldata_work(). Can you add in XmlListModel element this code and comment out the content of that function:
              @
              if (status === XmlListModel.Ready) console.log("XmlListModel.Ready ", count);
              if (status === XmlListModel.Loading) console.log("XmlListModel.Loading");
              if (status === XmlListModel.Error) console.log("XmlListModel.Error: ", errorString);
              if (status === XmlListModel.Null) console.log("XmlListModel.Null");@

              1 Reply Last reply
              0
              • C Offline
                C Offline
                cokefish
                wrote on last edited by
                #7

                Do you means that change
                @function do_xmldata_work()
                {
                console.log("do_xmldata_work begin>: ")
                while(xmlModel.status != XmlListModel.Ready)
                console.log("loading xml file: " + xmlModel.status)
                console.log("loading xml file: " + xmlModel.status + " || finished")

                    ...
                }@
                

                into
                @function do_xmldata_work()
                {
                console.log("do_xmldata_work begin>: ")
                //while(xmlModel.status != XmlListModel.Ready)
                // console.log("loading xml file: " + xmlModel.status)
                if (status === XmlListModel.Ready) console.log("XmlListModel.Ready ", count);
                if (status === XmlListModel.Loading) console.log("XmlListModel.Loading");
                if (status === XmlListModel.Error) console.log("XmlListModel.Error: ", errorString);
                if (status === XmlListModel.Null) console.log("XmlListModel.Null");

                    console.log("loading xml file: " + xmlModel.status + " || finished")
                
                    ...
                }@
                
                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  deimos
                  wrote on last edited by
                  #8

                  oh sorry. I forgot to write the signal. I mean this:

                  @XmlListModel {
                  id: xmlModel
                  ....
                  onStatusChanged: {
                  if (status === XmlListModel.Ready) console.log("XmlListModel.Ready ", count);
                  if (status === XmlListModel.Loading) console.log("XmlListModel.Loading");
                  if (status === XmlListModel.Error) console.log("XmlListModel.Error: ", errorString);
                  if (status === XmlListModel.Null) console.log("XmlListModel.Null");
                  }

                  }@

                  and do not call do_xmldata_work() function. Just for testing and see if the xml file has problems

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    cokefish
                    wrote on last edited by
                    #9

                    OK, I will try, it may cost some time on both platforms
                    Thank you very much.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      cokefish
                      wrote on last edited by
                      #10

                      Using
                      @ XmlListModel {
                      id: xmlModel
                      ....
                      onStatusChanged: {
                      if (status === XmlListModel.Ready) console.log("XmlListModel.Ready ", count);
                      if (status === XmlListModel.Loading) console.log("XmlListModel.Loading");
                      if (status === XmlListModel.Error) console.log("XmlListModel.Error: ", errorString);
                      if (status === XmlListModel.Null) console.log("XmlListModel.Null");
                      }

                      }@
                      
                      • On desktop: Only one line output
                        @XmlListModel.Loading
                        XmlListModel.Ready 4@

                      • On Qtembedded: Only one line output
                        @XmlListModel.Loading@

                      1 Reply Last reply
                      0
                      • C Offline
                        C Offline
                        cokefish
                        wrote on last edited by
                        #11

                        It seems that on Qtembedded platform, that the loading never finished.
                        Why, am I using the the wrong path of the xml file?

                        1 Reply Last reply
                        0
                        • D Offline
                          D Offline
                          deimos
                          wrote on last edited by
                          #12

                          bq. Why, am I using the the wrong path of the xml file?

                          That was my first thought, but if XmlModelList doesn't find the file an Error or Null signal should be emitted. You also can try to store the xml file in a known directory and set the source property with the full path.
                          What is your embedded platform ?

                          1 Reply Last reply
                          0
                          • C Offline
                            C Offline
                            cokefish
                            wrote on last edited by
                            #13

                            I have tried the absolute path before, it will output all the same.
                            In fact, I do not know what my embedded platform is.
                            I only know that the toolchain is from freescale,
                            for that the compiler is called as "arm-fsl-linux-gnueabi-g++" with a "fsl", I guessed that it was a freescale platform.
                            Maybe iMx53 serials. But I do not know exactly.

                            If this is a bug, where the bug is locating in your mind.
                            In the "qmlapplicationviewer" source in my project,
                            or somewhere underneath in the Qt framework?

                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              cokefish
                              wrote on last edited by
                              #14

                              with a wrong path
                              @source: "errorxmldata.xml"@
                              on Desktop outputs
                              @XmlListModel.Loading
                              XmlListModel.Error: [object Object]@

                              while on Qtembeded platform
                              @XmlListModel.Loading
                              XmlListModel.Error: [object Object]@

                              The same as you thought.

                              1 Reply Last reply
                              0
                              • D Offline
                                D Offline
                                deimos
                                wrote on last edited by
                                #15

                                Sorry but I have no more suggestions.
                                I searched if there is some on "bugreports":https://bugreports.qt-project.org but didn't found any. You can try there to file a new bug reporting on which platform you find it.

                                good luck

                                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