summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/componentCreation.js
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-04-28 23:59:28 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-04-28 23:59:28 (GMT)
commit9c97294f12fa155e90a702d952460b4911504a92 (patch)
treee8949c1a03702fdfa9d5e56381e0ea5327c337d6 /doc/src/snippets/declarative/componentCreation.js
parent6b0a0f14b20d16977f902a025b61ebbd54e72fc4 (diff)
parentfd7c1acef4bd3b1aa4b160592af140bd87c21829 (diff)
downloadQt-9c97294f12fa155e90a702d952460b4911504a92.zip
Qt-9c97294f12fa155e90a702d952460b4911504a92.tar.gz
Qt-9c97294f12fa155e90a702d952460b4911504a92.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'doc/src/snippets/declarative/componentCreation.js')
-rw-r--r--doc/src/snippets/declarative/componentCreation.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js
new file mode 100644
index 0000000..be3e4d6
--- /dev/null
+++ b/doc/src/snippets/declarative/componentCreation.js
@@ -0,0 +1,57 @@
+//![0]
+var component;
+var sprite;
+
+function finishCreation() {
+ if (component.isReady) {
+ sprite = component.createObject();
+ if (sprite == null) {
+ // Error Handling
+ } else {
+ sprite.parent = appWindow;
+ sprite.x = 100;
+ sprite.y = 100;
+ // ...
+ }
+ } else if (component.isError()) {
+ // Error Handling
+ console.log("Error loading component:", component.errorsString());
+ }
+}
+//![0]
+
+//![1]
+function createSpriteObjects() {
+//![1]
+
+ //![2]
+ component = Qt.createComponent("Sprite.qml");
+ if (component.isReady)
+ finishCreation();
+ else
+ component.statusChanged.connect(finishCreation);
+ //![2]
+
+ //![3]
+ component = Qt.createComponent("Sprite.qml");
+ sprite = component.createObject();
+
+ if (sprite == null) {
+ // Error Handling
+ console.log("Error loading component:", component.errorsString());
+ } else {
+ sprite.parent = appWindow;
+ sprite.x = 100;
+ sprite.y = 100;
+ // ...
+ }
+ //![3]
+
+//![4]
+}
+//![4]
+
+//![5]
+createSpriteObjects();
+//![5]
+