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.point...@gmail.com>
Sent: March 1, 2019 4:46 PM
To: Jérôme Godbout <godbo...@amotus.ca>
Cc: Qt Project <interest@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 
<godbo...@amotus.ca<mailto:godbo...@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.

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to