[Qt-interest] Q_CLASSINFO interface name and preprocessor

Arnold Krille arnold at arnoldarts.de
Fri Jul 3 20:45:05 CEST 2009


Hi,

On Thursday 02 July 2009 23:19:40 Will Rutherdale (rutherw) wrote:
> Is there any way to control the second parameter to Q_CLASSINFO() so
> that it can be automatically varied by project?  For instance:
> class MyTenThousandthAdaptor : public QdbusAbstractAdaptor
> {
>     Q_OBJECT
>     Q_CLASSINFO( "D-Bus Interface", PROJECT_PREFIX "ten_thousandth" )
> // ...
> };
> The point being that if I could somehow induce the moc compiler to
> expand PROJECT_PREFIX into a string constant, then all code compiled in
> the same way would magically come out as "com.foobolts.ten_thousandth"
> one time, and "com.barbolts.ten_thousandth" another time.
> I've tried it both through the preprocessor and through the moc
> command-line, trying to push a definition through for PROJECT_PREFIX,
> without success.
> Most of the documentation indicates that macro expansion doesn't work
> with the moc compiler, but I would like to find out from others if there
> is any way to work this, before I give up.

I think that idea is pretty good. One way I think this could be made to work: 
Adopt moc so it expands macros.
Another idea: Hack your way into the metaObject to modify the classInfo stuff. 
You would have to reimplement QObject::metaObject() to return your own 
metaObject which returns the right stuff for the class-info...
But actually I think it would be more fun (and more usable for others) if moc 
got some pre-processor abilities.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090703/d5b6afec/attachment.bin 


More information about the Qt-interest-old mailing list