[Qt-interest] QVariant::type() usage for custom QVariant types
Thiago Macieira
thiago at kde.org
Thu Jul 28 16:34:57 CEST 2011
On Thursday, 28 de July de 2011 16:21:35 Eckhard Jokisch wrote:
> Thanks for the relply.
> I already tried that one - but how do I define the number that
> userType() shall return? there is not something like
>
> variant.setUserType(int type,QString typeName)?
>
> I need to know at compiletime what number will be returned - otherwise
> I can't use "switch".
You don't define it.
The number is computed at runtime when you register the type (via
qRegisterMetaType). The value returned from the registration is the ID you
have to use.
You can also get the same ID by calling qMetaTypeId<Type>().
So: you can't use a switch.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
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/20110728/a65663be/attachment.bin
More information about the Qt-interest-old
mailing list