[Qt-interest] typedef on the same underlying type and Q_REGISTER_METATYPE

Thiago Macieira thiago at kde.org
Tue Sep 13 20:45:35 CEST 2011


On Tuesday, 13 de September de 2011 20.14.52, MARTIN Pierre wrote:
> > struct Ratio { qreal data; };
> > struct PositiveRatio { qreal data; };
> > struct NegativeRatio { qreal data; };
> > Q_DECLARE_TYPEINFO(Ratio, Q_MOVABLE_TYPE)
> > Q_DECLARE_METATYPE(Ratio)
> > Q_DECLARE_TYPEINFO...
> 
> Appologies, i have found the informations i was looking for about
> Q_DECLARE_TYPEINFO... However i don't understand how one could register a
> new POD datatype for instance let's say compatible with assignment, +=, -=,
> /=, etc without redefining either a template class wrapping it, or
> something similar...

You need to define the operators, yes. But remember you must have concrete 
classes, not typedefs to template instantiations.

The MOVABLE is to tell QVector and QList that they can memcpy this type with 
impunity.

-- 
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/20110913/697567a4/attachment.bin 


More information about the Qt-interest-old mailing list