summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative/componentCreation.js
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-05-05 18:54:19 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-05-05 18:54:19 (GMT)
commit0a8379d9f01118d7ff0121e6ecbbc0307e1e7f63 (patch)
treedbbf96df4245ecd37d9c9f0b619afaf6ddd19e38 /doc/src/snippets/declarative/componentCreation.js
parent337dbd5391b4e2b1bd88918a46f3392df8fd1312 (diff)
downloadQt-0a8379d9f01118d7ff0121e6ecbbc0307e1e7f63.zip
Qt-0a8379d9f01118d7ff0121e6ecbbc0307e1e7f63.tar.gz
Qt-0a8379d9f01118d7ff0121e6ecbbc0307e1e7f63.tar.bz2
Make component.createObject require a parent argument
For graphical objects (the common case) a common mistake is to not parent a dynamically created item. Since you almost always want to add a parent, and it's hard for a beginner to diagnose this problem, a parent is now a required argument and dealt with by the createObject function. Task-number: QTBUG-10110
Diffstat (limited to 'doc/src/snippets/declarative/componentCreation.js')
-rw-r--r--doc/src/snippets/declarative/componentCreation.js8
1 files changed, 2 insertions, 6 deletions
diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js
index be928f0..f6fb379 100644
--- a/doc/src/snippets/declarative/componentCreation.js
+++ b/doc/src/snippets/declarative/componentCreation.js
@@ -4,11 +4,10 @@ var sprite;
function finishCreation() {
if (component.status == Component.Ready) {
- sprite = component.createObject();
+ sprite = component.createObject(appWindow);
if (sprite == null) {
// Error Handling
} else {
- sprite.parent = appWindow;
sprite.x = 100;
sprite.y = 100;
// ...
@@ -32,13 +31,12 @@ else
//![2]
component = Qt.createComponent("Sprite.qml");
-sprite = component.createObject();
+sprite = component.createObject(appWindow);
if (sprite == null) {
// Error Handling
console.log("Error loading component:", component.errorsString());
} else {
- sprite.parent = appWindow;
sprite.x = 100;
sprite.y = 100;
// ...
@@ -47,5 +45,3 @@ if (sprite == null) {
}
-createSpriteObjects();
-