Created
January 10, 2019 19:56
-
-
Save curtwagner1984/4bb39e7ff02e5cef9d02178621cfe054 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import QtQuick 2.10 | |
| import QtQuick.Controls 2.4 | |
| import QtQuick.Window 2.2 | |
| import QtQuick.Controls.Material 2.3 | |
| import QtQuick.Layouts 1.3 | |
| ApplicationWindow { | |
| id: appWindow | |
| Material.theme: Material.Dark | |
| title: qsTr("Test QML") | |
| visible: true | |
| width: 640 | |
| height: 480 | |
| function referenceLoaderText(){ | |
| console.log("Loader text:" + myLoader.item.text) | |
| } | |
| Rectangle { | |
| id: myRec | |
| anchors.fill: parent | |
| color: 'grey' | |
| ListView{ | |
| anchors.fill: parent | |
| model: 10 | |
| delegate: Loader{ | |
| id:myLoader | |
| source: "MyButton.qml" | |
| onLoaded: { | |
| console.log("Loader loaded") | |
| referenceLoaderText() | |
| } | |
| } | |
| // Component.onCompleted: { | |
| // console.log("Referencing loader item: " + myLoader.item.text) | |
| // } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have 10 Loaders since it is inside ListView. Which of these Loaders do you mean when using the id myLoader?
the delegates load components, and the components have local id (they exist only within the component), what is your objective? What do you want to do with the text? You have 10 Loaders with 10 texts, to which of these texts do you want to obtain?