[Qt-interest] Q_CLASSINFO interface name and preprocessor

Frank Hemer frank at hemer.org
Fri Jul 3 21:14:35 CEST 2009


On Friday 03 July 2009 20:45:05 Arnold Krille wrote:
> 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.

There is a patch availabe to provide basic macro expansion, its mentioned in 
the task tracker and the patch is available from the mailing list.

Frank



More information about the Qt-interest-old mailing list