Hi again and sorry for all the spam :) I´ve now managed to use XmlListModel with ListView to implement some parts of my slide show, but somehow I think I now could use a XmlTreeModel or something.
Let´s say the XML looks like this: <root> <slideshow> <name>My First slide show</name> <slide id="1"> <image>http://example.com/img1.jpg"</image> <audio>http://example.com/snd1.mp3"</audio> <text>Some text...</text> </slide> <slide id="2"> <image>http://example.com/img42.jpg"</image> <audio>http://example.com/snd42.mp3"</audio> <text>Some other text...</text> </slide> </slideshow> <slideshow> <name>My second slide show</name> <slide>[...]</slide> <slide>[...]</slide> </slideshow> </root> Now I can create a XmlListModel like this: XmlListModel { id: slideshowModel source: "slideshow.xml" query: "/root/slideshow/slide" XmlRole { name: "img"; query: "image/string()" } XmlRole { name: "text"; query: "image/text()" } } So far, so good. I will get all sides from my first slide show. But how can I, for example, access the <name> element of <slideshow>? And how can I access the other slide shows? I would like to have a list, where each element looks like this: * slide show name: /root/slideshow/name/string() * slide text: /root/slideshow/slide/text/string() * slide image: /root/slideshow/slide/image/string() * More... I tried adding a XmlRole that accesses the parent element like: XmlRole { name: "parentName"; query: "../name/string()" } But without success. Is it possible to do something like that with XmlListModel? Thanks again! Conny Am 06.08.2010 13:57, schrieb Cornelius Hald: > Hi, > > I´m new to QML and Qt, so please excuse my beginner questions. To get > acquainted with QML I´m trying to do a small multi-media slide show > thing. Basically it should show pictures with some text and play some > audio file. A simple XML model could look like this: > > <slideshow> > <slide id="1"> > <image>http://example.com/img1.jpg"</image> > <audio>http://example.com/snd1.mp3"</audio> > <text>Some text...</text> > </slide> > > [...] > > <slide id="42"> > <image>http://example.com/img42.jpg"</image> > <audio>http://example.com/snd42.mp3"</audio> > <text>Some other text...</text> > </slide> > > </slideshow> > > My view should have a 'previous' and a 'next' button and always show one > picture + text + audio. Once someone clicks the 'next' button the next > slide should be shown. > > Building the view was no problem and it´s working as expected, the > problem is how to build the model for the view and how to present it to > the view. (The view is just a .qml file, so not a view like the e.g. the > ListView.) > > I´ve looked at ListModel and XmlListModel and I think they provide all I > need on the model side. Then for the view part I looked at ListView, > GridView and PathView, but somehow those views are made to show all > items at once and I only want to display one item a time. > > Do I have to create my own *View class? If yes, do I have to do this > with C++ or is there a way to build a custom view using only QML/JS? I > was trying to pass a ListModel into my view just by binding properties, > but that doesn´t seem to work. > > It could be that I´m missing something obvious here, if so, please tell > me :) > > All pointers would be very much appreciated and if something is unclear > I´ll provide more information. > > Thanks! > Conny > _______________________________________________ > Qt-qml mailing list > Qt-qml@trolltech.com > http://lists.trolltech.com/mailman/listinfo/qt-qml _______________________________________________ Qt-qml mailing list Qt-qml@trolltech.com http://lists.trolltech.com/mailman/listinfo/qt-qml