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. Seek advice on how to store data structure of qml
Forum Updated to NodeBB v4.3 + New Features

Seek advice on how to store data structure of qml

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 4 Posters 5.5k 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.
  • F Offline
    F Offline
    franziss
    wrote on last edited by
    #1

    Dear all, I seek your advice on data structure of qml. We are implementing a powerpoint-like application using qml.
    For each slide, we can add objects such as pictures, texts, videos, etc. How do we store these content of each slide? I think the main problem is the content to be stored is unstructured, as a alide can contain different number of objects.

    Any suggestion?

    Thank you for your help.

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

      Hi franziss, i think the basic and helpful way to store the data is, using xml. And, you can have a look at the "QML presentation system":http://labs.qt.nokia.com/2011/05/30/a-qml-presentation-system/#comment-22367 here :)

      Chuck

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aalpert
        wrote on last edited by
        #3

        JSON might be easier than XML for data storage. QML can load JSON into javascript objects quite easily, and you can manipulate it from there. If you use XML, you'll probably need to import a XML->JSON JS library.

        But you can always just store the content in QML, especially if you want create a QML object for each 'data object'. At its core, QML is just a language for creating a hierarchy of objects with property initializations (and bindings).

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dialingo
          wrote on last edited by
          #4

          I would be very interested in seeing a video of your powerpoint clone once it is ready. Qt Quick is a new technology with users still testing the limits and developers removing obstacles in the way. To me it looks like you are about to go boldly where no man has gone before.

          I have seen only one thing which tries to achieve this:
          http://doc.qt.nokia.com/4.7/declarative-toys-dynamicscene.html

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

            @aalpert: Yes, JSON is more easier and smaller for data storage, but how about a well-designed XmlListModel, and for cases that we want munipulate the data in Qt C++ ? If there is a way can make us munipulate the data in both QML(or js) and Qt C++ using JSON ? I remember Qt C++ doesn't has a JSON parsing API itself.

            Br,

            Chuck

            1 Reply Last reply
            0
            • F Offline
              F Offline
              franziss
              wrote on last edited by
              #6

              Thank you guys for your advices and suggestions.

              @Chuck.Gao: XmlListModel is good if multiple devices need to communicate with each other, and data can be transferred between each device via xml. According to this example http://doc.qt.nokia.com/4.7-snapshot/qml-xmllistmodel.html#details, it seems that the data must be structured. We can assume that each <item> is a slide, but the objects in the slide are unstructured, that is, we can have as many number and different types of objects in the slide. So can xml handle unstructured data or a qml data?

              @aaplert: can JSON handle unstructured data? Your suggestion on directly using qml is interesting. Is it possible that I create a qml file for each slide, which defines the slide and its objects. So when I load the slide, I will read from its corresponding qml file. And when I amend the slide, I will write to the corresponding qml file? Or I will need to use c++ as the middle man between Qt and the qml file?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aalpert
                wrote on last edited by
                #7

                You can use QtScript to parse JSON from C++, or do it in QML and pass the JS object into C++.

                @franziss JSON and XML can handle unstructured data as 'lists of objects', much like the QML default property. While there is no built in facility to write QML files from C++ due to the difficulty of a complete system, in the simple case it should be very easy to iterate through the generated objects and print out property values through object-introspection (this would not preserve any bindings). This would have to be done in C++ though - if only because QML by default does not have file writing capabilities.

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  franziss
                  wrote on last edited by
                  #8

                  Hi aaplert,

                  Ok, thank you, I get it now, xml can handle unstructured data as follows:

                  @
                  <?xml version="1.0" encoding="utf-8"?>
                  <slide>
                  <object>
                  ...... more details
                  </object>
                  <object>
                  ...... more details
                  </object>
                  </slide>
                  <slide>
                  <object>
                  ...... more details
                  </object>
                  <object>
                  ...... more details
                  </object>
                  </slide>
                  @

                  1 Reply Last reply
                  1

                  • Login

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