[Development] QML CheckBox, ComboBox & QObject property bindings

Juan Navarro oneorjuan at gmail.com
Fri Jul 11 01:47:43 CEST 2014


Hi; I'm trying to better understand what are de limitations of the
bindings when using QObject properties in my QML files, as it seems to
work in a different way depending on the Component used.

Say my app manages several instances of QObject* data items, which
have 3 Q_PROPERTies: text, bool and number. The C++ side will set a
QML property with one of those instances, and the QML side allows to
edit the object properties through a TextField, a CheckBox and a
ComboBox. Nothing fancy so far. Actually this is what is explained
here:
http://qt-project.org/doc/qt-5/qtqml-cppintegration-exposecppattributes.html

Problems start to appear when the C++ side changes the object
instances on the QML property: the TextField will automatically catch
the change and show the new text, but the other Components won't
update themselves.
This is a real inconvenience because I had found that this pattern of
"injecting data items into QML" really simplifies the manipulation of
data from a QML UI.

I have created a full and working example consisting of both basic
QObject property accesses and Object-Type data:
https://dl.dropboxusercontent.com/u/315932/QtItemDataTest.zip

Clicking on buttons 1, 2 & 3 and editing the fields, will show how all
values are properly stored on their corresponding data objects, but
Components won't load their corresponding values.

Could you please enlighten me about this issue?
Regards,
Juan Navarro



More information about the Development mailing list