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

Jérôme Godbout godboutj at amotus.ca
Fri Mar 1 23:00:02 CET 2019


You can also give CBor implementation a look,maybe it could fit your bill too:

https://doc.qt.io/qt-5/qcbormap.html


From: Sylvain Pointeau <sylvain.pointeau at gmail.com>
Sent: March 1, 2019 4:46 PM
To: Jérôme Godbout <godboutj at amotus.ca>
Cc: Qt Project <interest at qt-project.org>
Subject: Re: [Interest] using a custom class as parameter of signal/slot, used in QML

On Fri, Mar 1, 2019 at 10:29 PM Jérôme Godbout <godboutj at amotus.ca<mailto:godboutj at amotus.ca>> wrote:
Why is the struct deleted one the signal is finished? You create a structure only for the signal? it’s not an object or data that will outlive that call in the end? If so, you really need to make a copiable representation of the struct.

Yes it is just an object created for the time of the signal, to avoid having 5 parameters to my signal.


What kind of data live into your struct? are they all basic type or pointer? or do you have QObject into it?
QVariantMap seem like an easy way out.

it is (for now) just integers, I just tried QVariantMap (just after my previous email), I find it good enough, I will stay with this I think.

JSON serialization or even better QDataStream (which is really fast compare to JSON) could help you do it. You could do an operator<<() and operator>>() with QDataStream on your struct to do it. QByteArray are copiable.

If you can provide more information about your struct data that could help.

it is just basic data for now.

But I would really wish that Qt could do that for us so I can just keep on using my structure.

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


More information about the Interest mailing list