[Qt-qml] setContextProperty and Property bindings
Schmidt
dres-schmidt at t-online.de
Mon Oct 25 20:09:51 CEST 2010
Solved!
My fault, did Set private member outside property.
Regards,
Mike
Von meinem iPhone gesendet
Am 24.10.2010 um 22:26 schrieb Schmidt <dres-schmidt at t-online.de>:
> Hi there,
> I have a small class with one property. It is exposed from c++ to qml via setContextProperty().
> But when i change The property in c++ and emit the NOTIFY signal the property is not changed in qml. I can set and read the value in qml perfectly.
>
> In c++:
> Class menu {
> Q_PROPERTY(int d, ... NOTIFY dChanged())
>
> Q_INVOKABLE int test { setD(1); return 1; }
> ...
> Void setD(int val) { If (val!=m_d) { m_d=val; emit dChanged();}
> ...
> }
>
> In main():
> Setcontextproperty(menu,,"menu");
>
> and in qml:
>
> TextInput {
> focus: (menu.d == 1)
>
> MouseArea {
> onClicked: test()
> ... if called dChanged() is emitted but ...focus does not change.
>
> If i write...
> onClicked: menu.d = test()
> it works.
>
> So how do i set binding properly ?
> Thank you,
>
> Mike,
> _______________________________________________
> Qt-qml mailing list
> Qt-qml at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-qml
More information about the Qt-qml
mailing list