[Interest] Value objects in QML context
roland.m.winklmeier at gmail.com
Mon Oct 7 19:45:36 CEST 2013
I couldn't find anything usefull in the internet, so I hope you can help
me in a design question.
I'm part of a project using QML for the UI. Since we have several value
classes, we came across a problem with exposing this value objects into
the QML context.
Lets assume I have a class CLocation with member variables for Latitude
double Latitude() const;
double Longitude() const;
void setLatitude(const double latitude);
void setLongitude(const double longitude);
specificly saying, I should not derive from QObject for this kind of
But how can I access this setters and getters now in QML? Lets say I
have a QMap of cities with its CLocations.
In C++ I would call QMap::value() to get the CLocation by the city name
and call the getter or do something else with the object. In QML I can't
to anything similar, because its not accessable in the QML context. Do I
really have to wrap around a QObject derived class, to call the setters
and getters or how is this meant to be? Did I maybe miss something? I'm
sure the designers of QML had such use cases in mind and I'm just not
recognize the easy solution.
Limiting the access to QObjects only in an UI seems strange to me. I
understand the technic behind with Qt Metatype system, but isn't that
Thanks for your help.
More information about the Interest