[Interest] Qt::Alignment and MetaObject System

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Thu Aug 29 19:09:52 CEST 2013


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.

Hope this helps,
-- 
Join us at Qt Developer Days 2013! - https://devdays.kdab.com
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
KDAB (UK) Ltd., a KDAB Group company
Tel. UK +44-1738-450410, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4048 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130829/dc24963b/attachment.bin>


More information about the Interest mailing list