[Interest] using a custom class as parameter of signal/slot, used in QML

ekke ekke at ekkes-corner.org
Fri Mar 1 17:02:43 CET 2019


I find it easier the other way ;-)

whereever it is possible, I'm using QObject* for my data
there's a special C++ DataManager class with Q_INVOKABLE methods to
create / delete / .... and this class always is the parent of my QObject*

it's cool - there's no by-value copying between C++ and QML and I'm
getting code-completion in QML on all the Q_PROPERTY and I'm always
using the same objects,
so it's easy to call a C++ utility using the QObject* or exposing the
QObject* to QML

the nice thing: my datamodel is defined using a custom DSL based on
(Eclipse) XText and XTend and all the C++ code for my Entities and the
DataManager is generated from this model.
hopefully some day I'll find the time to publish this generator as
OpenSource

ekke

Am 01.03.19 um 16:12 schrieb Jason H:
> Check out qtmultimedia/examples/multimedia/video/qmlvideofilter_opencl
> fo the filter result types. I think that's what you want?
>  
> I find it easier to code and work with to just rely on QVariant
> conversion. QVariantList and QVariantMap are transparently converted
> to JS Objects. 
>  
> *Sent:* Friday, March 01, 2019 at 6:43 AM
> *From:* "Sylvain Pointeau" <sylvain.pointeau at gmail.com>
> *To:* "Qt Project" <interest at qt-project.org>
> *Subject:* [Interest] using a custom class as parameter of
> signal/slot, used in QML
> Dear all,
>  
> I understood how to use a struct / simple class as a parameter of a
> signal / slot, and it works well by value.
>  
> However as soon as we have to declare the type for QML, it is not good
> anymore.
> It seems that it must be derived from QObject and passed by pointer.
>  
> Do I understand well that the QML world does only accept pointers on
> QObject?
>  
> However I don't understand, who owns the pointer of the custom class
> (derived from QObject) and who actually deletes it?
> (I tried a sharepointer but QML does not know how to handle it)
>  
> Do you have any idea?
>  
> Best regards,
> Sylvain
>  
>  
> _______________________________________________ Interest mailing list
> Interest at qt-project.org https://lists.qt-project.org/listinfo/interest
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/d5590664/attachment.html>


More information about the Interest mailing list