[SOLVED]Signal from dynamic component to the page where it is created
-
Hi,
QML newbie here. I made a timer that generates dynamic components in QML. I need help in changing values from the page (where the component was created) whenever I interact with those components (ex: clicking the dynamic component changes a variable value/component property in the page where it was created), something like signals and slots. How do I do this? Thanks in advance!
-
Im not sure if this will help you, but :
@
import QtQuick 1.0Rectangle {
id: rect
width: 360
height: 360
property string my_text: "hello world"Text { id: textBox anchors.centerIn: parent text: rect.my_text } MouseArea { id: mouseArea anchors.fill: parent onClicked: { textBox.color = "blue"; rect.my_text = "goodbye world" } } states: State { name: "change color"; when: mouseArea.pressed PropertyChanges { target: rect; color: "blue"; } }
}
@ -
Thanks for the reply, actually my problem is that my dynamic component is on another QML file..
@Page {
id: splashscreen
rotation: 0Rectangle { id:rect color: "#d3ff20" anchors.fill: parent Rectangle { id: house width: 80; height: 80 color: "#00000000" x: 280 y: 245 Image { id: name source: "images/evernote.png" anchors.fill: parent } } ProgressBar { width: 200 height: 50 x: 220; y:310 maximumValue: 100 minimumValue: 0 value: 100 MouseArea { anchors.fill: parent } } Timer { interval: 800 running: true repeat: true onTriggered: { if (Qty.currentAliensCount < 10) { createItem(Math.floor(Math.random()*10000)T0, Math.floor(Math.random()*10000)$0) Qty.currentAliensCount += 1; } } } } function createItem(mx,my) { //the dynamic component from a separate qml.. var component = Qt.createComponent("TestItem1.qml"); var sprite = component.createObject(splashscreen,{"x": mx,"y":my}); }
}@
And I need to access the properties of components on this page whenever I click the TestItem1 dynamic component
-
up! :)
-
I removed the javascript and created properties instead :)