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 link two QML files using XMLListModel?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] How to link two QML files using XMLListModel?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.3k 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

    Okay. Let me try to be clear here.

    "Attachment":http://i214.photobucket.com/albums/cc71/honeyhong/Capture.jpg

    For example, I have a list as such, and the data (a list of array) are retrieved from an XML file.
    Each of the data is supposed to be linked to its own respective page.

    Right now, when onClicked, I could link to other page, but as a whole. Meaning when i click any data, it will all link to the same page.
    I want to click on the data individually (the yellow area) and each link to its own page.

    I couldn't preset a name for each of the data in list element and call it, because since these data are retrieved from a XML file,
    it will always be updated and the amount of data may change every time it is updated.

    Anyone can tell me how to do it?

    I hope I am clear. Really need some solution.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chriadam
      wrote on last edited by
      #2

      Define an onClicked handler for each delegate, which uses data passed to it by the model (ie, attached property or whatever). Each item in the model will have separate links/array data, I assume.

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

        [quote author="chriadam" date="1341980227"]Define an onClicked handler for each delegate, which uses data passed to it by the model (ie, attached property or whatever). Each item in the model will have separate links/array data, I assume.[/quote]
        Got it. Solved.
        Thank you for your tips. :)

        For reference, here are my codes :
        //page1
        @
        import QtQuick 1.1
        import com.nokia.symbian 1.1
        import "../js/Util.js" as Util
        import "../delegates"

        Page {
        id: container
        property string itemTitle: ""
        signal feedItemSelected(string title)

        XmlListModel {
            id: test1
            property string feedUrl: ""
            property bool loading: status == XmlListModel.Loading
        
            source: "http:// (put in the url)"
            query: "/plist/array/dict"
        
            XmlRole { name: "details"; query: "string[1]/string()" }
        

        }

         ListView {
                id: list1
                anchors {
                    left: parent.left
                    right: parent.right
                    top: headBar.bottom
                    bottom: parent.bottom
                    }
        
                clip: true
                model: test1
                delegate: listDelegate1
            }
        
            Component {
                id: listDelegate1
        

        //settings of the details to be displayed in TestItem.qml
        TestItem
        { text1: details
        onClicked:
        {
        Util.log("Clicked ....on " + details)
        container.itemTitle = details
        feedItemSelected(details)

                        onFeedItemSelected:
                        {
                        Util.log("Selected feed item");
                        pageStack.push(feedItemView);
                        }
                    }
        

        //link to page 2
        Page2 {
        id: feedItemView
        width: parent.width
        itemTitle: container.itemTitle
        }
        }
        }
        @

        I have another file which are placed in the same folder that defines the settings of the text to be displayed in Page 1 called TestItem1.qml

        @
        //TestItem.qml
        import QtQuick 1.1
        import "../js/Util.js" as Util

        Item {
        id: container
        property string text1: "DETAILS"

        signal clicked
        width: parent.width
        height: Math.max(54, itemText1.itemTextHeight)
        clip: true
        

        Text {
        id: itemText1
        property int itemTextHeight: height + anchors.topMargin + anchors.bottomMargin
        text: container.text1

        }
        

        MouseArea {
        id: mouseArea
        anchors.fill: parent
        onClicked: container.clicked();

        }
        

        }
        @

        solved. thanks for your help :)

        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