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. XmlListModel
Qt 6.11 is out! See what's new in the release blog

XmlListModel

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

    I typed a sample, but it displayed nothing in tableView, Did I do anything wrong?
    @import QtQuick 2.1
    import QtQuick.Controls 1.0
    import QtQuick.Window 2.0
    import QtQuick.Layouts 1.0
    import QtQuick.XmlListModel 2.0

    ApplicationWindow {
    id: root
    title: qsTr("L2 Tool")
    width: 500
    height: 360
    TableView {
    id: flickerTable
    TableViewColumn {
    title: "Column 1"
    role: "title"
    }
    model: flickerModel
    }

    XmlListModel{
        id: flickerModel
        source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=Cat"
        query: "/rss/channel/item"
        namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
        XmlRole { name: "title"; query: "title/string()" }
        XmlRole { name: "date"; query: "pubDate/string()" }
        XmlRole { name: "source"; query: "media:thumbnail/@url/string()" }
        XmlRole { name: "credit"; query: "media:credit/string()" }
    }
    

    }@
    !http://xiangce.baidu.com/picture/detail/ba52e93a7a2aaf584f66189f103f5b0762ca05dc(pic)!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      Gennon
      wrote on last edited by
      #2

      Seems ok, and I got it to work with adding visible = true for the ApplicationWindow and I also made the TableView cover the whole window with anchors.fill: parent.

      @import QtQuick 2.1
      import QtQuick.Controls 1.0
      import QtQuick.XmlListModel 2.0

      ApplicationWindow {
      id: root
      title: qsTr("L2 Tool")
      width: 500
      height: 360
      visible: true

      TableView {
          id: flickerTable
          anchors.fill: parent
          TableViewColumn {
              title: "Column 1"
              role: "title"
          }
          model: flickerModel
      }
      
      XmlListModel{
          id: flickerModel
          source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags=Cat"
          query: "/rss/channel/item"
          namespaceDeclarations: "declare namespace media=\"http://search.yahoo.com/mrss/\";"
          XmlRole { name: "title"; query: "title/string()" }
          XmlRole { name: "date"; query: "pubDate/string()" }
          XmlRole { name: "source"; query: "media:thumbnail/@url/string()" }
          XmlRole { name: "credit"; query: "media:credit/string()" }
      }
      

      }
      @

      /Gen

      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