How to display QML screen from the JavaScript code.
-
wrote on 3 Oct 2011, 06:12 last edited by
How to display QML screen from the JavaScript code, on some external events i need to display new QML screen from the javascript code.
To load new QML screen we need to use Loader and we need to change the source of the loader to display the new screen.
I want to display new QML screen on top of the existing QML screen from the javascript.Thanks.
-
wrote on 3 Oct 2011, 07:24 last edited by
Hello,
"Dynamic Object Management in QML article":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html might help you.
-
wrote on 3 Oct 2011, 07:36 last edited by
Hi,
Thanks for the reply,
Does "component.createObject(appWindow, {"x": 100, "y": 100});" creates and displays QML object on the screen? Suppose I have text box in the QML file which i am going to create using "createObject", so how should I set the text of that text box. is it something like this "newQmlObject.testTextBox.text = 'this is test';" or is there any other way?Thanks.
-
wrote on 3 Oct 2011, 08:04 last edited by
Yes, component.createObject() will create and display object on position 100, 100. Also it returns an object instance of this component, so you are able to modify it`s properties.
For eample:
@
var cmp = component.createObject(appWindow, {“x”: 100, “y”: 100});
cmp.width = 100;
@Also you can use "createQmlObject":http://doc.qt.nokia.com/4.7-snapshot/qml-qt.html#createQmlObject-method . You should decide what is best in your case.
-
wrote on 3 Oct 2011, 09:46 last edited by
Ok go it, but can we access components/widgets (not properties) in side the newly created qml object? Also how can remove a screen from the display.
-
wrote on 3 Oct 2011, 10:43 last edited by
To remove object you can call your_object.destroy(ms_to_wait_before_removing_object) (see "Deleting objects dynamically":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativedynamicobjects.html#deleting-objects-dynamically )
You can access items inside created component throught "children property":http://doc.qt.nokia.com/4.7-snapshot/qml-item.html#children-prop , but I think it will be easier to use "property aliases":http://doc.qt.nokia.com/latest/qml-extending-types.html#property-aliases for children properties you need.
6/6