[Interest] question about moveToThread docs

Sze Howe Koh szehowe.koh at gmail.com
Wed Feb 11 00:34:32 CET 2015


Hi,

On 11 February 2015 at 06:48, Alan Ezust <alan.ezust at gmail.com> wrote:
> from the documentation of QObject::moveToThread():
>
>     \note A QObject's member variables \e{do not} automatically become
>     its children. The parent-child relationship must be set by either
>     passing a pointer to the child's \l{QObject()}{constructor}, or by
>     calling setParent(). Without this step, the object's member variables
>     will remain in the old thread when moveToThread() is called.
>
> Is this talking about member variables of type QObject ?
> As in, "subobjects" ?

It is talking about member variables of type "QObject*" -- pointers to
QObject. I believe that's the recommended practice.


> subobjects of type QObject that also have a parent set, might get destructed
> twice, but is that what this above paragraph is recommending?

They won't get destructed twice if your member variable is a pointer,
rather than the full object.


Regards,
Sze-Howe



More information about the Interest mailing list