summaryrefslogtreecommitdiffstats
path: root/examples/declarative/dynamic
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-04-19 11:42:49 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-04-21 07:13:51 (GMT)
commit202af3021362d3c8066bc479a95e7aad889bd928 (patch)
tree03587443c77403321c18e384b3277abd576e9ba3 /examples/declarative/dynamic
parent2ac290f56c6ad4f3e236034a7b99ecdb598ecc3a (diff)
downloadQt-202af3021362d3c8066bc479a95e7aad889bd928.zip
Qt-202af3021362d3c8066bc479a95e7aad889bd928.tar.gz
Qt-202af3021362d3c8066bc479a95e7aad889bd928.tar.bz2
Make the dynamic creation functions on the Qt object
Also updated examples to still work, and the dynamic example now uses exceptions a little, to demonstrate that it can be done. Exceptions are also now filled out with the QML error data. Task-number: QT-2801 Reviewed-by: Aaron Kennedy
Diffstat (limited to 'examples/declarative/dynamic')
-rw-r--r--examples/declarative/dynamic/dynamic.qml37
-rw-r--r--examples/declarative/dynamic/qml/itemCreation.js2
2 files changed, 37 insertions, 2 deletions
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index eea528f..0e6e197 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -7,6 +7,34 @@ Item {
//This is a desktop-sized example
width: 1024; height: 512
property int activeSuns: 0
+
+ //This is the message that pops up when there's an error
+ Rectangle{
+ id: dialog
+ opacity: 0
+ anchors.centerIn: parent
+ width: dialogText.width + 6
+ height: dialogText.height + 6
+ border.color: 'black'
+ color: 'lightsteelblue'
+ z: 65535 //Arbitrary number chosen to be above all the items, including the scaled perspective ones.
+ function show(str){
+ dialogText.text = str;
+ dialogAnim.start();
+ }
+ Text{
+ id: dialogText
+ x:3
+ y:3
+ font.pixelSize: 14
+ }
+ SequentialAnimation{
+ id: dialogAnim
+ NumberAnimation{target: dialog; property:"opacity"; to: 1; duration: 1000}
+ PauseAnimation{duration: 5000}
+ NumberAnimation{target: dialog; property:"opacity"; to: 0; duration: 1000}
+ }
+ }
// sky
Rectangle { id: sky
@@ -114,7 +142,14 @@ Item {
}
Button {
text: "Create"
- onClicked: createQmlObject(qmlText.text, window, 'CustomObject');
+ function makeCustom() {
+ try{
+ Qt.createQmlObject(qmlText.text, window, 'CustomObject');
+ }catch(err){
+ dialog.show('Error on line ' + err.qmlErrors[0].lineNumber + '\n' + err.qmlErrors[0].message );
+ }
+ }
+ onClicked: makeCustom();
}
}
}
diff --git a/examples/declarative/dynamic/qml/itemCreation.js b/examples/declarative/dynamic/qml/itemCreation.js
index ccc03aa..4fa0d9f 100644
--- a/examples/declarative/dynamic/qml/itemCreation.js
+++ b/examples/declarative/dynamic/qml/itemCreation.js
@@ -31,7 +31,7 @@ function loadComponent() {
if (itemComponent != null) //Already loaded the component
createItem();
- itemComponent = createComponent(itemButton.file);
+ itemComponent = Qt.createComponent(itemButton.file);
//print(itemButton.file)
if(itemComponent.isLoading){
component.statusChanged.connect(finishCreation);