Details
-
Bug
-
Resolution: Cannot Reproduce
-
P2: Important
-
None
-
5.2.0
-
Windows 7 32-bit MinGW 48_32
Description
From the standard example from the documentation, the following code should create the button object asynchronously and initialise the parent and some properties.
This worked fine in Qt 5.1.1 but does not work now in Qt 5.2.0.
var component = Qt.createComponent("Button.qml"); var incubator = component.incubateObject(parent, { x: 10, y: 10 }); if (incubator.status != Component.Ready) { incubator.onStatusChanged = function(status) { if (status == Component.Ready) { print ("Object", incubator.object, "is now ready!"); } } } else { print ("Object", incubator.object, "is ready immediately!"); }
Note that the following code does work and can be used as a temporary workaround.
var component; var button; function createObjects() { component = Qt.createComponent("Button.qml"); if (component.status == Component.Ready) finishCreation(); else component.statusChanged.connect(finishCreation); } function finishCreation() { if (component.status == Component.Ready) { button = component.createObject(parent, {"x": 10, "y": 10}); if (button == null) { // Error Handling console.log("Error creating object"); } } else if (component.status == Component.Error) { // Error Handling console.log("Error loading component:", component.errorString()); } }