[Development] QMetaTypeId and QMetaTypeId2

Thiago Macieira thiago.macieira at intel.com
Thu Feb 9 10:42:07 CET 2012


On Thursday, 9 de February de 2012 10.07.16, Jedrzej Nowacki wrote:
> Hi,
> 
>   Does anybody know why we have separation between QMetaTypeId and
> QMetaTypeId2 classes?

Because the original QMetaTypeId that existed in Qt 4.0 lacked one important 
feature, which Harald fixed in 4.2 or 4.3.

Before harryF's changes, the Q_DECLARE_METATYPE macro did not save the name, 
so you had to include the type's name in the registration function:

	qRegisterMetaType<MyType>("MyType");

This was necessary because the type's name cannot be easily gleaned from the 
template parameter (I have a patch for that though, see https://codereview.qt-
project.org/#change,670 ). 

>   QMetaTypeId2 delegates all operations to QMetaTypeId by default and
> qMetaTypeId() function is calling QMetaTypeId2. To make it more complex
> Q_DECLARE_METATYPE is specializing QMetaTypeId but
> Q_DECLARE_BUILTIN_METATYPE is specializing QMetTypeId2. From an user
> perspective it is not visible, but it makes implementation complex.
> 
>   Can I merge QMetaTypeId and QMetaTypeId2?

Yes. Those are not public classes.

There was some Harmattan code that specialised them and broke when we made 
some changes in 4.7, but touching those classes is internal API.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120209/3dd5c40c/attachment.sig>


More information about the Development mailing list