[Qt-interest] Q_CLASSINFO interface name and preprocessor

Clinton Stimpson clinton at elemtech.com
Fri Jul 3 21:06:58 CEST 2009


Will Rutherdale (rutherw) wrote:
> Hi.
>
> 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.
>
> Any help would be appreciated.
>
>   
How about generating a header file with the substitution?

Clint



More information about the Qt-interest-old mailing list