[Qt-interest] Q_DECLARE_METATYPE and abstract classes
Schimkowitsch Robert
Robert.Schimkowitsch at andritz.com
Tue Aug 9 17:38:13 CEST 2011
Thanks, that was exactly the pointer (sic!) I needed.
Is there a way to make it work with const references instead of
pointers, too?
Kind regards
Robert Schimkowitsch
-----Original Message-----
From: qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.com
[mailto:qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.co
m] On Behalf Of Thiago Macieira
Sent: Monday, August 08, 2011 2:26 PM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] Q_DECLARE_METATYPE and abstract classes
On Monday, 8 de August de 2011 12:36:16 Schimkowitsch Robert wrote:
> > How do I declare a metatype of an abstract base class? I have seen
> > nothing in the Q_DECLARE_METATYPE-docs that would forbid it.
You don't. Metatypes require being default-constructible, publicly
destructible, copyable and assignable.
Abstract types cannot be constructed at all. By definition of abstract
as well,
you don't want to copy them, as doing that would shear the specialised
object
you had.
More than likely, you want to register the metatype of the *pointer* to
the
abstract class.
> > I need the metatype to create a Q_PROPERTY of (a pointer to) that
> > abstract type. The compiler errors are clear enough: It wants to
> > create a new object of that type, which doesn't work with an
abstract
> > class.
See? That proves all I said above: you cannot have a metatype of an
abstract
type and you want the pointer to the type.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
#####################################################################################
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
Thank You.
#####################################################################################
More information about the Qt-interest-old
mailing list