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



  • 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?



  • I solved myself... :-)

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



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



  • [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.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.