[Qt-interest] Constructing a QEnum with only a metatypeid.

Thiago Macieira thiago at kde.org
Tue Aug 9 01:01:52 CEST 2011


On Monday, 8 de August de 2011 20:43:06 MARTIN Pierre wrote:
> Hello,
> 
> Regarding my previous post, it may be too complicated after all. Below is a
> simplified version of the question…
> 
> Can someone provide me with an example of code showing how to construct a
> QVariant "v", based on a given QVariant::UserType "t" where "t" refers to a
> type registered for an enum type?  

QVariant v(t, 0);

The value will be default constructed. I hope you like your enums of value 0. 
The 0 above is not the value, it's a null pointer.

> Then when using qDebug() << v; i expect
> the type as well as the value to appear in stdout...

It will print the type name but not the value. Printing the value is not 
possible.

-- 
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/20110809/a64459cc/attachment.bin 


More information about the Qt-interest-old mailing list