Deactivate checked Checkbox if a certain condition is met?
-
I've got a qml-checkbox connected to a cpp-class like this:
@CheckBox {
id: check
checked: cppInterface.checker
onCheckedChanged: cppInterface.setChecker(check.checked,true)
}@When it's checked or unchecked setChecker is executed.
In setChecker I check if the Checkbox was activated, if yes, I check further if the condition is met.
If not I want to uncheck the CheckBox again using setchecker. That doesn't work for some reasons.It is connected to C++ like this:
@Q_PROPERTY(bool checker READ isChecker WRITE setChecker NOTIFY checkerChanged)
public:
bool isChecker()
Q_INVOKABLE void setChecker(bool value, bool emitSignal);
signals:
void checkerChanged();
private:
m_checker;@setChecker is looking like this:
@void QmlCppMediator::setChecker(bool value, bool emitSignal){
m_checked = value;if (emitSignal){
emit checkerChanged();
}}@
-
If it works as it is, it would go in to infinite loop.. May be it being detected by compiler and disallowed it.
And one more thing is that setChecker function should take only one argument that is bool ( it is a setter function for m_checker ). Can you make one more function to make call from QML to CPP, and not mix it work setChecker.
-
Normally you'd be right but QML seems to be intelligent about these loops. It gives a warning but doesn't actually go into that loop.
I tried everything you said, simplyfying the example more and more. While I can change the checked state of that component I could never change it visually.
That's why I reported it as a bug here:
"Your text to link here...":http://bugreports.qt.nokia.com/browse/QTCOMPONENTS-910