02-08-2013 06:23 PM
I am looking for a way to prevent certain functions from being run when a QML page is loaded. For example, a checkbox : onCheckChanged{} signal. When my page is loaded, it runs the code I have in the onCheckChanged section.
I am only having these issues with Javascript/QML functions, not C++. Any suggestions to prevent this?
Thanks
02-09-2013 10:43 AM
I use a simple technique to good effect.
In either the top-level component of the page in question, or the individual item in question, add a boolean property to flag whether you're initialized yet. I try to be creative so I call it "initialized". Set it true by default.
In the onCreationCompleted, do stuff then set it false at the end.
Then in the handler itself, just return immediately if it's not initialized.
Pseudo-example:
Page {
property bool initialized: false
CheckBox {
onCheckedChanged: {
if (!initialized) return;
// do regular stuff here
}
}
onCreationCompleted: {
// do initialization stuff here...
initialized = true;
}
}
02-11-2013 08:10 AM