Hi,
Can someone help me regarding the creation of dynamic objects in QML?
I followed the example on this link http://doc.qt.nokia.com/4.7-snapshot...icobjects.html cause I wanted to create something similar.
I created the example as is ( Sprite.qml and main.qml ), as well as the javascript file.
var component;
var sprite;
function createSpriteObjects() {
component = Qt.createComponent("Sprite.qml");
if (component.status == Component.Ready)
finishCreation();
else
component.statusChanged.connect(finishCreation);
}
function finishCreation() {
if (component.status == Component.Ready) {
sprite = component.createObject(appWindow, {"x": 100, "y": 100});
if (sprite == null) {
// Error Handling
console.log("Error creating object");
}
} else if (component.status == Component.Error) {
// Error Handling
console.log("Error loading component:", component.errorString());
}
}
var component;
var sprite;
function createSpriteObjects() {
component = Qt.createComponent("Sprite.qml");
if (component.status == Component.Ready)
finishCreation();
else
component.statusChanged.connect(finishCreation);
}
function finishCreation() {
if (component.status == Component.Ready) {
sprite = component.createObject(appWindow, {"x": 100, "y": 100});
if (sprite == null) {
// Error Handling
console.log("Error creating object");
}
} else if (component.status == Component.Error) {
// Error Handling
console.log("Error loading component:", component.errorString());
}
}
To copy to clipboard, switch view to plain text mode
Works fine but the setting of properties x and y on line 14 does not work.
Is this a bug, or is there something I'm missing? Thank you for your help!
Bookmarks