[Interest] Best way to QObject-wrap simple objects

K. Frank kfrank29.c at gmail.com
Wed Feb 20 03:47:08 CET 2013

Hi Tony!

On Tue, Feb 19, 2013 at 6:13 PM, Tony Rietwyk <tony at rightsoft.com.au> wrote:
> Hi Frank,
>> Sent: Wednesday, 20 February 2013 12:19 AM
>> Hello List!
>> Sometimes I have a simple class, maybe a POD, that I want to pump through
>> a queued signal-slot connection.  As I understand it, I need a QObject to
> do
>> that.  So I wrap my class in QObject.
> You can pass pointers to the POD without doing anything else:
> signals:
>         void my_signal(POD *data);

Thanks for noting that.

It seems a little odd, though.  I could of sworn I tried passing a reference:

   void my_signal (const POD &data)

and it failed at run time when I tried to pass the reference through a
queued connection.

Of course, pointers and references are not identical, but, under the
hood, you would think that if a queued connection could handle one,
it could handle the other.

Is it in fact the case that queued connections can handle pointers
but not references (to non-qmetatypes), or am I just misremembering
what I did?

> If it really must be POD by value, then use Samuel's approach.

Well, in my case it certainly doesn't have to be by value, but by
value or by reference stylistically reflects the by-value semantics
of the POD.

> Tony.


K. Frank

More information about the Interest mailing list