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 problem
QtWS25 Last Chance

[solved] XmlListModel problem

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

    Hi,

    I can't get this model to work:

    @XmlListModel {
    id: xmlModel
    source: "http://gdata.youtube.com/schemas/2007/categories.cat"
    query: "/app:categories/atom:category"

        namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; \
                    declare namespace yt='http://gdata.youtube.com/schemas/2007';"
    
        XmlRole { name: "term";  query: "yt:@term/string()" }
        XmlRole { name: "label"; query: "yt:@label/string()" }
    

    }@

    the xml contains:

    @<?xml version='1.0' encoding='utf-8'?>
    <app:categories xmlns:app='http://www.w3.org/2007/app'
    xmlns:atom='http://www.w3.org/2005/Atom'
    xmlns:yt='http://gdata.youtube.com/schemas/2007' fixed='yes'
    scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>
    <atom:category term='Film' label='Film & Animation' xml:lang='en-US'>
    <yt:assignable />
    <yt:browsable regions='AR ... ZA' />
    </atom:category>
    [...]@

    I don't understand what I have to do. Any suggestions ?

    thanks a lot
    Marco

    1 Reply Last reply
    0
    • AlicemirrorA Offline
      AlicemirrorA Offline
      Alicemirror
      wrote on last edited by
      #2

      Hi, deimos,

      after the definition of the XmlListModel based on the XMLS file, did you created also the other components? Do you to show this file in a list ?

      It should be defined the delegate and the list...

      Enrico Miglino (aka Alicemirror)
      Balearic Dynamics
      Islas Baleares, Ibiza (Spain)
      www.balearicdynamics.com

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

        Hi Alicemirror,

        thanks for the reply.
        I tried to learn XQuery all the night, but just for luck I got what I wanted ;)
        Yes I use the XmlListModel as a model in a GridView. Here the working code:

        @Rectangle {
        id: categoryButtons

        XmlListModel {
            id: xmlModel
            source: "http://gdata.youtube.com/schemas/2007/categories.cat"
            query: "/categories/atom:category"
        
            namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2007/app';"+
            "declare namespace atom='http://www.w3.org/2005/Atom';"+
            "declare namespace yt='http://gdata.youtube.com/schemas/2007';"
        
            XmlRole { name: "term";  query: "@term/string()" }
            XmlRole { name: "label"; query: "@label/string()" }
        }
        
        GridView {
            id: buttonsGridView
            model: xmlModel
            delegate: MDcomboButton {
                width: 100
                height: 50
                text: label+" - "+term
            }
        
            cellWidth: parent.width/8
            cellHeight: cellWidth/2
            width: parent.width
            height: parent.height
        }
        

        }@

        but I still don't understand the query statement: why it has not the "app:" beside "categories" ? I should learn more about these :)

        thanks again

        1 Reply Last reply
        0
        • AlicemirrorA Offline
          AlicemirrorA Offline
          Alicemirror
          wrote on last edited by
          #4

          Hi Deimos,

          bq. but I still don’t understand the query statement: why it has not the “app:” beside “categories” ? I should learn more about these :)

          What does it means ? I tried to understand it without results :)

          Enrico Miglino (aka Alicemirror)
          Balearic Dynamics
          Islas Baleares, Ibiza (Spain)
          www.balearicdynamics.com

          1 Reply Last reply
          0
          • AlicemirrorA Offline
            AlicemirrorA Offline
            Alicemirror
            wrote on last edited by
            #5

            AAaaaahhhhhh :-(

            Sorry, now I see. It is in your xml.

            Well, if it can help you, everytime I see a new "dialect" of the xml I became crazy to understand what it means.

            I think that this is a useful link to understand exactly what does means your xml file: http://www.w3.org/standards/xml/

            Advice: keep it in your bookmarks :)

            Enrico Miglino (aka Alicemirror)
            Balearic Dynamics
            Islas Baleares, Ibiza (Spain)
            www.balearicdynamics.com

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

              bq. everytime I see a new “dialect” of the xml I became crazy to understand what it means.

              Exactly my feeling :)
              thanks for that link... bookmarked

              1 Reply Last reply
              0
              • AlicemirrorA Offline
                AlicemirrorA Offline
                Alicemirror
                wrote on last edited by
                #7

                Yep. It maybe a good idea to post a wiki page with a simplified but useful version of the most frequent cases of how the xml can be expressed...

                Enrico Miglino (aka Alicemirror)
                Balearic Dynamics
                Islas Baleares, Ibiza (Spain)
                www.balearicdynamics.com

                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