[Interest] using a custom class as parameter of signal/slot, used in QML
sylvain.pointeau at gmail.com
Fri Mar 1 21:26:54 CET 2019
On Fri, Mar 1, 2019 at 5:25 PM Jérôme Godbout <godboutj at amotus.ca> wrote:
> Since signal are not sync all the time but can be async, the argument need
> to be copiable to allow this. So you need to be able to copy the arguments
> on the signals. Therefore the QObject is not copiable, they cannot be
> passed as arguments directly, you need a pointer. The ownership and
> lifetime of that object is up to you, but you need it to live until all
> handler have finish processing the signal (this can be longer then the
> signal emit for queued connection).
Not only it can be asynchrone but also multiple "listeners". One consumer
might be QML, one other might be another Object.
The lifetime is simply impossible to predict, and the ownership is really
if the copy would have been possible, we could have used a reference
If you can easily copy the structure you probably can serialize/deserialize
> it or put it into a QVariant, QVariantList or QVariantMap. That would be
Yes, I agree, this is just another mechanism to implement. I just did it in
Json for one object but this is not ideal neither, but workable. (I
hesitate with QVariant)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest