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

Sylvain Pointeau sylvain.pointeau at gmail.com
Fri Mar 1 17:14:37 CET 2019


Hello Jerome,

On Fri, Mar 1, 2019 at 3:34 PM Jérôme Godbout <godboutj at amotus.ca> wrote:

> The fact that the QObject is non copiable, is one of the reason it need a
> pointer (which can be copied). As for the ownership, you can check with the
> qqmlengine:
>
> https://doc.qt.io/qt-5/qqmlengine.html#objectOwnership
>
>
>

I have understood it yes


> You can change the ownership too with setOwnership(). I for one exposed
> the methods to Qml so each side can check/set the qobject ownership based
> on the needs. This is very helpful to debug.
>
> You can use QPointer to have a pointer that will return to null if the
> qobject get deleted.
>

OK but I thought a signal should be quite generic, and not necessarily
consumed by QML.
but maybe we should design special signals for QML, is this what you
suggest?

I would find more convenient to be able to send a structure by copy, so
consumed as it is by QML (wrapped in QML and ownership set to QML)

Best regards,
Sylvain

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 6751 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 1016 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.png
Type: image/png
Size: 483 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image004.png
Type: image/png
Size: 506 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image005.png
Type: image/png
Size: 500 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image006.jpg
Type: image/jpeg
Size: 713 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20190301/aa8cd370/attachment-0002.jpg>


More information about the Interest mailing list