Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

How do I attach properties to a Component?

$
0
0
Hi there, I am trying to understand the Component objects. So I’ve written two .qml files. Container.qml, which is a Rectangle that displays an arbitrary object (aThing). The other file (main.qml) is the application, which uses ‘Container’ to display the object that is defined within main.qml. Now to my question: how do I attach properties (pass information) form from ‘Container’ to ‘aThing’? main.qml: import QtQuick 2.0   Rectangle {     width: 360; height: 360     color: "aliceblue"       Rectangle {         anchors.centerIn: parent         width: 300; height: 300         border {color: "black"; width: 1 }           Container {             id: container             anchors.margins: 1               aThing: Rectangle {                 width: 50; height: 50;                                 // I know, this does not work. But how can I get Component.qml                 // to pass information to this 'aThing'                 color: Qt.darker(container.theColor, .5)             }         }     } } Container.qml: import QtQuick 2.0   Rectangle {     property color theColor: "lightsteelblue"     property Component aThing: idDefaultComponent       Component {         id: idDefaultComponent         Rectangle { width: 100; height: 100; color: "red" }     }       anchors.fill: parent     color: theColor       Loader {         id: thing         anchors.centerIn: parent         sourceComponent: aThing     } }

Viewing all articles
Browse latest Browse all 18427

Trending Articles