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. [Solved] XmlListModel, set source from C++ QByteArray
QtWS25 Last Chance

[Solved] XmlListModel, set source from C++ QByteArray

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 2.8k Views
  • 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all, I have a QByteArray in C++ with the content of an xml file.
    I expose the QByteArray to QML:
    @
    QByteArray elenco_satelliti;
    ...
    ...
    m_qmlViewer->rootContext()->setContextProperty("elencoSatelliti", elenco_satelliti);
    @

    Now I'd like to use the QByteArray as XmlListModel "source":
    @
    XmlListModel {
    id: elencoSatellitiModel
    source: elencoSatelliti
    query: "/satelliti/satellite"

        XmlRole { name: "idSatellite"; query: "id/string()" }
        XmlRole { name: "descrizioneSatellite"; query: "descrizione/string()" }
    }
    

    @

    but setting the source this way doesn't works...

    Is it possible?

    1 Reply Last reply
    0
    • L Offline
      L Offline
      luca
      wrote on last edited by
      #2

      I solved myself... :-)

      @
      source: "data:binary," + elencoSatelliti
      @

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

        Instead of source property, I think you can aslo use:
        @
        xml: elencoSatelliti@

        1 Reply Last reply
        0
        • L Offline
          L Offline
          luca
          wrote on last edited by
          #4

          [quote author="deimos" date="1332960516"]Instead of source property, I think you can aslo use:
          @
          xml: elencoSatelliti@[/quote]

          Thanks, I just tried and it works.

          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