[Development] Question about Qt's future

Kevin Krammer kevin.krammer at kdab.com
Mon Apr 21 18:53:22 CEST 2014


On Monday, 2014-04-21, 14:52:25, Roland Winklmeier wrote:
> >> - Our application has a huge framework of value classes. They cannot (or
> >> at least it does not make sense to) derive from QObject for several
> >> reasons. But subclassing QObject is the requirement to access data from
> >> C++ in QML. So we had our framework of well designed value classes and
> >> cannot use them in QML. There were evaluations to create QObject
> >> wrappers, but no nice solution. So no support for value classes is
> >> probably a show stopper for many projects. With Widgets we were able to
> >> use them easily.
> > 
> > Hmm, I’m not sure what you mean by value classes.  Do you mean literally
> > data models?  You don’t need to move QObjects across to QML if you are
> > just sending data for display in the UI.  We have lots of complicated
> > data types that we simply save in QVariantMaps, and they show up as
> > javascript objects in QML. You may not have this flexibility, but as the
> > application designer on our project I don’t allow anyone to put new
> > classes into QML from c++ unless they directly drive a viewable element,
> > because that contaminates the view layer with business logic, following
> > the MVC pattern.  I wouldn’t allow that with widgets either.
> The term value classes is due to history reasons in our project. We
> started creating classes to handle physical values. Hence the name.
> Some of them are data models representing entities (e.g. aircrafts) and
> also abstract items (e.g. altitude, callsign, flightplan). All these
> classes have an advanced API and logic written in C++, for example
> CAltitude has complex API methods to get the value in different units.
> We also use them as a property/value for example to assign it to an
> aircraft: setAltitude(const CAltitude &altitude).

If you already have them as property values, what kind of operation do you 
need to do in QML that requires JS bindings for those objects?

> If I want to access this methods from QML I would have to derive them
> from QObject and register it in the QML context.

Not necessarily, depends on what you want to do.
However, it is true that it would be nice to have something similar to 
QtScript's binding facilities.

> For the time being it was a lot easier to call a c++ method
> getAltitude(AltitudeUnit unit) from QtWidgets than QML :)

You mean if the method is in a different class then the enum definition?

Cheers,
Kevin
-- 
Qt Developer Days 2014, October 6 - 8 at BCC, Berlin. Save the dates!

Kevin Krammer | kevin.krammer at kdab.com | Senior Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5918 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140421/146bafc6/attachment.bin>


More information about the Development mailing list