PDA

View Full Version : Slot connecting ordering issue vs properties



CCob
22nd October 2011, 13:52
Hi,

I have developed a Qt Quick compatible Component in C++, that exposes properties and a signal. It seems the ordering of setting properties and connecting signals is not working for me. The component has a property where it's READ function within the C++ class could emit a signal. The issue seems to be though that the property value is being set before the signal from the class is connected, so because of this the receiving QML object doesn't receive the signal as it seems it's not connected yet.

If I change the location where the property is set, say from an onClicked of a MouseArea component then the signal is received correctly.

example:



MsiInstaller{

id:msi
msiFile: "installer.msi";

onException: {
console.log("Exception thrown: code " + code);
}
}


the msiFile property, when setting, can cause the exception signal to be thrown. But when done like the example above, the onException slot is not fired. If I comment out the msiFile line and set the property elsewhere, it works as expected.

Is there a way to make sure the slots are connected before the properties are set.

Thanks.

Added after 14 minutes:

I have altered it so that the property is not set until Component.onCompleted is fired. Is that the best approach? Thanks.