[Interest] Qt::Alignment and MetaObject System

Martin Koller kollix at aon.at
Fri Aug 30 08:27:48 CEST 2013


On Thursday 29 August 2013 19:09:52 Giuseppe D'Angelo wrote:
> Il 29/08/2013 17:11, Martin Koller ha scritto:
> > However how can I do the same with this Qt::AlignmentFlag enum which is not defined inside a QObject ?
> 
> There's a trick in place in qnamespace.h:
> 
> http://code.woboq.org/qt5/qtbase/src/corelib/global/qnamespace.h.html#50
> 
> So: most(all?) enums under the Qt namespace gets actually extracted by 
> moc, and placed in a special metaobject, accessible in any QObject 
> subclass (it's protected): QObject::staticQtMetaObject.
> 
> So you can use something like
> 
>  > int index = staticQtMetaObject.indexOfEnumerator("Alignment");
>  > QMetaEnum me = staticQtMetaObject.enumerator(index);
>  > ...
> 
> in a QObject subclass to get the meta information about Qt::Alignment.

Thanks to this trick - works great!

A pitty it's not documented ...

-- 
Best regards/Schöne Grüße

Martin
A: Because it breaks the logical sequence of discussion
Q: Why is top posting bad?

()  ascii ribbon campaign - against html e-mail 
/\  www.asciiribbon.org   - against proprietary attachments

Geschenkideen, Accessoires, Seifen, Kulinarisches: www.bibibest.at



More information about the Interest mailing list