[Qt-interest] Q_CLASSINFO interface name and preprocessor
Will Rutherdale (rutherw)
rutherw at cisco.com
Fri Jul 3 20:54:00 CEST 2009
> 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
Very well expressed.
Thanks for confirming that it isn't currently supported.
-Will
More information about the Qt-interest-old
mailing list