QProperty; binding and onValueChanged
-
I'm not getting quite what I am expecting with QProperty bindings and onValueChanged(...)
It seems that if I am tracking a property (i.e. QProperty::onValueChanged(...)) which is bound
to another QProperty, and is also bound to by a third QProperty.My original code is much bigger then this, but I was able to reproduce my issue with the
following code:#include <QProperty> #include <QDebug> int main( int, char** ) { QProperty< bool > p{ true }; QProperty< bool > pp{ [&](){ return p.value(); } }; QProperty< bool > ppp{ [&](){ return pp.value(); } }; auto ch1{ p.onValueChanged( [&](){qDebug() << "p changed to:" << p.value(); } ) }; auto ch2{ pp.onValueChanged( [&](){qDebug() << "pp changed to:" << pp.value(); } ) }; auto ch3{ ppp.onValueChanged( [&](){qDebug() << "ppp changed to:" << ppp.value(); } ) }; qDebug() << p.value() << pp.value() << ppp.value(); qDebug() << "\np.setValue( false );"; p.setValue( false ); qDebug() << p.value() << pp.value() << ppp.value(); qDebug() << "\np.setValue( true );"; p.setValue( true ); qDebug() << p.value() << pp.value() << ppp.value(); return 0; }
The output I get is the following:
true true true p.setValue( false ); ppp changed to: false p changed to: false false false false p.setValue( true ); ppp changed to: true p changed to: true true true true
I.e. the value of all the QProperty objects are changing as expected, but
the lamda for pp.onValueChanged is not executed. I.e. I whould have expected
the following to be printed:true true true p.setValue( false ); ppp changed to: false pp changed to: false p changed to: false false false false p.setValue( true ); ppp changed to: true pp changed to: true p changed to: true true true true
Are my expectations wrong or have I encountered a bug?
My version of Qt I build from git, cloned today, using the dev branch, following the guide
on the wiki, -developer-build. -
@Eirik said in QProperty; binding and onValueChanged:
it is the fact that pp.onValueChanged(...) is never triggered I am wondering
Yes, that's what I was interested in, the order of calls is something I had suspected, that's why I wanted to understand what you get as output in this case.
-
@Eirik said in QProperty; binding and onValueChanged:
order of calls seems not to matter
It may be a bug, I suggest you post on the interest mailing list where this can get more exposure (you can reference this forum thread in your mail).