From kde-devel Fri May 02 21:14:56 2008 From: "Nathan Bradshaw" Date: Fri, 02 May 2008 21:14:56 +0000 To: kde-devel Subject: Re: Private classes and Q_Objects Message-Id: <92af7fc70805021414p72ee2b69r61b7f34dcc28ff22 () mail ! gmail ! com> X-MARC-Message: https://marc.info/?l=kde-devel&m=120976295619836 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============1267233210==" --===============1267233210== Content-Type: multipart/alternative; boundary="----=_Part_17509_20542284.1209762896491" ------=_Part_17509_20542284.1209762896491 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline cool, thanks very much for the answer Thiago. So the private class is just cleaned up by deleting d_ptr in the public class' destructor as per usual practice? cheers Nathan On Fri, May 2, 2008 at 4:41 PM, Thiago Macieira wrote: > Nathan Bradshaw wrote: > >Hi all, I have a situation where I have a library with a private class / > >s_ptr arrangement. I need to create an instance of a Q_OBJECT derived > > class in the private class. What is the best method of parenting the > > Q_OBJECT in the private class? > > > >Should I derive the private class from Q_OBJECT and make it the parent? > >Should I use Q_DECLARE_PUBLIC / Q_Q() to get the private class' parent > >(itself a Q_OBJECT derived class) and use that as the parent? > > The private class(es) should derive from QObject, have the Q_OBJECT macro, > but they should have no parent. > > You'll control the lifetime of that class directly. > > -- > Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org > PGP/GPG: 0x6EF45358; fingerprint: > E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358 > > > >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to > unsubscribe << > > ------=_Part_17509_20542284.1209762896491 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline cool, thanks very much for the answer Thiago.

So the private class is just cleaned up by deleting d_ptr in the public class' destructor as per usual practice?

cheers
Nathan


On Fri, May 2, 2008 at 4:41 PM, Thiago Macieira <thiago@kde.org> wrote:
Nathan Bradshaw wrote:
>Hi all, I have a situation where I have a library with a private class /
>s_ptr arrangement. I need to create an instance of a Q_OBJECT derived
> class in the private class. What is the best method of parenting the
> Q_OBJECT in the private class?
>
>Should I derive the private class from Q_OBJECT and make it the parent?
>Should I use Q_DECLARE_PUBLIC / Q_Q() to get the private class' parent
>(itself a Q_OBJECT derived class) and use that as the parent?

The private class(es) should derive from QObject, have the Q_OBJECT macro,
but they should have no parent.

You'll control the lifetime of that class directly.

--
  Thiago Macieira  -  thiago (AT) macieira.info - thiago (AT) kde.org
    PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


------=_Part_17509_20542284.1209762896491-- --===============1267233210== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe << --===============1267233210==--