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] How to retrieve data from a XmlListModel to another XmlListModel?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to retrieve data from a XmlListModel to another XmlListModel?

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

    Hey, I want to call a data from a XmlListModel to another XmlListModel which is in a different page.
    Here are my codes

    @ //Page1
    XmlListModel {
    id: products1
    property string feedUrl: ""
    property bool loading: status == XmlListModel.Loading

        source: "http://appsfactory.my/client/canonmsia2/android/fws/products1.php"
        query: "/plist/dict/array/dict"
    
        XmlRole { name: "icon1"; query: "string[1]/string()" }
        XmlRole { name: "category1"; query: "string[2]/string()" }
        XmlRole { name: "products2"; query: "string[3]/string()" } //want to make this as source in Page2
    

    }

    ListView {
        id: list1
        anchors {
            left: parent.left
            right: parent.right
            top: parent.top
            bottom: parent.bottom
            rightMargin:8
            leftMargin:5
            topMargin: header.height + headBar.height + (window.height > 640 ? 270 : 210)
        }
        clip: true
        model: products1
        delegate: listDelegate1
    }
    
    Component {
        id: listDelegate1
    
        Products1Item{
            icon_p1_item: icon1;
            category_p1_item: category1
    
            onClicked:
            {
                 Util.log("Clicked on " + products2 + " product1")
                 Util.log("Selected feed item" + products2);
                 pageStack.push(Qt.resolvedUrl("Page2.qml"));
            }
    
        }
    }
    

    //Page2

    XmlListModel {
        id: products2
        property string feedUrl: ""
        property bool loading: status == XmlListModel.Loading
    
        source: " "  //products2 from XmlListModel in Page1
        query: "/plist/dict/array/dict"
    
        XmlRole { name: "icon2"; query: "string[1]/string()" }
        XmlRole { name: "category2"; query: "string[2]/string()" }
        XmlRole { name: "products3"; query: "string[3]/string()" }
    

    }

    @

    I want to place products2 from the first XmlListModel(Page1) as a source in the 2nd XmlListModel (Page2).
    I hope I am clear enough. Can anyone teach me how to do it?

    i tried this source : products1.get(0).products2 but can't work.

    1 Reply Last reply
    0
    • H Offline
      H Offline
      honeyhong
      wrote on last edited by
      #2

      It's okay I figured it out.
      On clicked i should put it like this,

      @ //Page1
      pageStack.push(Qt.resolvedUrl("Page2.qml"), {itemUrl2:products2, itemTitle2:category1})
      //set the properties in the bracket, linking to the name in the XmlListModel

      //Page2
      Page {
      id: container2
      property string itemUrl2: "" //set the property here
      property string itemTitle2: ""

      orientationLock: PageOrientation.LockPortrait
      FontLoader { id: fixedFont; source: "../fonts/CANON.ttf"}
      

      //---------------------------------xml----------------------------------------------
      XmlListModel {
      id: products2
      property string feedUrl: ""
      property bool loading: status == XmlListModel.Loading

          source: itemUrl2 //put the itemUrl2 here as source
          query: "/plist/dict/array/dict"
      
          XmlRole { name: "icon2"; query: "string[1]/string()" }
          XmlRole { name: "category2"; query: "string[2]/string()" }
          XmlRole { name: "products3"; query: "string[3]/string()" }
      

      }
      @

      Found this from, http://harmattan-dev.nokia.com/docs/library/html/qt-components/qt-components-meego-pagestack.html under Advanced Usage.

      Can use both of these ways for deep linking.
      @pageStack.push
      ([
      { page: pageOne, properties: { one: 1 } },
      { page: Qt.resolvedUrl("two.qml"), properties: { two: 2 }},
      ]);

      //or this
      pageStack.push(Qt.resolvedUrl("foo.qml"), {foo: bar, foz: baz }); @

      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