Re: How to use a script for a value property with QtQuick1 ?
Hi,
What is the best approach to work around the QtQuick1 limitations for this ?
ListElement: cannot use script for property value
remainingTimeElementRole: (function () { return (countDownTimerValue / 60 / 10).toFixed(0); }) ();
I began without a closure, and then I had that idea to try out, but apparently no go. :(
Here is the ListModel code:
Code:
ListModel {
id: remainingTimeModel;
ListElement {
remainingTimeElementRole: (countDownTimerValue / 60 / 10).toFixed(0);
}
ListElement {
remainingTimeElementRole: countDownTimerValue / 60 % 10;
}
ListElement {
remainingTimeElementRole: ":";
}
ListElement {
remainingTimeElementRole: (countDownTimerValue % 60 / 10).toFixed(0);
}
ListElement {
remainingTimeElementRole: countTimerDownTimerValue % 60 % 10;
}
}
Thank you in advance!
Added after 11 minutes:
Probably for loop in a Component.onCompleted block inside the ListModel, and call ListModel append() with the appropriate values is the simplest hack around. :/
Re: How to use a script for a value property with QtQuick1 ?
Define the function not as a lambda function but as a regular one and call it normally.
Code:
ListModel {
function remainingTime(val) { return (val / 60 / 10).toFixed(0); }
ListElement { remainingTimeElementRole: remainingTime(val); }
}