[Development] C++ QML Interface thoughts
Bo Thorsen
bo at vikingsoft.eu
Wed Jan 7 13:17:09 CET 2015
Den 06-01-2015 kl. 12:47 skrev Luke Parry:
> I am having issues trying to implement a c++ qml interface/wrapper that
> supports virtual overrides. Something functionally similar to
> boost::python would be excellent.
>
> This should be generic enough to also support non-QObject classes too so
> it rules out signals and slots. On first glance, it is fairly trivial to
> implement a wrapper that calls methods for the pointer, however
> implementing virtual overrides soon becomes difficult.
>
> I want to achieve something like this ( http://pastebin.com/t3k957Hf )
> In principle, this would work creating instances in QML but not the
> other way transforming from a c++ instance.
>
> Is this feasible with QML without some compromise? I would like to
> think I'm missing something subtle or something blatantly obvious.
Sounds to me like you're basically recreating the QObject based
connection between QML and C++ without using QObject.
That seems silly to me. If you're going to do this, accept that you're
using QObject based subobjects and then you don't need to do this at all.
Anyway, if you insist on doing this, the trick would probably be to make
the QObject wrapper object have a pointer to the real non-QObject
object. Use aggregation instead of inheritance.
Bo Thorsen,
Director, Viking Software.
--
Viking Software
Qt and C++ developers for hire
http://www.vikingsoft.eu
More information about the Development
mailing list