[Qt-interest] Q_DECLARE_METATYPE and abstract classes
Thiago Macieira
thiago at kde.org
Mon Aug 8 14:26:05 CEST 2011
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110808/99aa2498/attachment.bin
More information about the Qt-interest-old
mailing list