How to interact in between two QML screens?
-
wrote on 5 Oct 2011, 13:29 last edited by
How to interact in between two QML screens?
I am creating new QML component/screen by using "createComponent" and "createObject".@var component = Qt.createComponent("testQml.qml");
var sprite = component.createObject(parentWindow, {"x":0, "y":0});
if(sprite == null)
{
console.log("Error creating component\n");
return;
}
console.log("Screen Created\n");
// Send some data to the newly created screen
@I have some data that I need to pass it to the newly created screen before it displays the UI components.
I need two way communication in between child and the parent screen.
I also need to call some function of the parent QML screen from child screen.how it is done in the QML?
Thanks.
-
wrote on 7 Oct 2011, 09:34 last edited by
May be you can use properties and signals to pass data around ?
-
wrote on 7 Oct 2011, 11:59 last edited by
Can you please provide one example for this (using two qml/js files).
One way I found is common javascript file in between two QML files and from QML file accessing global key value pares (global array) to send and receive parameters across two QML files. -
wrote on 10 Oct 2011, 12:42 last edited by
Here.. Using a common Javascript file to share data.
Global.js
@
.pragma library
var sharedVariable = null;
@Your Screen1.qml
@
import "Global.js" as GlobalJSRectangle {
MouseArea {
anchors.fill:parent
onClicked: GlobalJS.sharedVariable = "This is shared data";
}
}
@Your Screen2.qml
@
import "Global.js" as GlobalJSRectangle {
Text {text: GlobalJS.sharedVariable
}
}
@ -
wrote on 10 Oct 2011, 12:45 last edited by
Thanks for the reply
1/5