[Interest] moc - specify include headers?

Charley Bay charleyb123 at gmail.com
Thu Jan 31 03:29:04 CET 2013


charley:

> > I'm using "qmake -tp vc" to generate MSVC *.vcproj files, works great.
> >  (Qt5, wrapping C++ classes for exposure to QML.)
> >
> > I'm doing some "tricky-template" stuff, and I *cannot* include the
> template
> > implementation in the "MyClass.hpp" header, but I *can* explicitly
> include
> > the template implementation into the the "MyClass.cpp".
> >
> > ISSUE:  The moc-generated "moc_MyClass.cpp" won't compile because it
> > *needs* my template implementation(s).  By default, it only includes
> > "MyClass.hpp", which is not enough (I need it to explicitly include my
> > template implementations).
>

thiago:

>
> #include "moc_MyClass.cpp" at the end of your MyClass.cpp.
>
> qmake will see the include and will not try to compile it separately.
>

Wow ... just wow.  That solves my problem completely.

I don't know what dark magic qmake employed to generate the better VCPROJ,
but this is so very cool.

> I *think* I need to go back to the "old-moc-workflow" where I "#include"
> > the moc-generated file directly into my "MyClass.cpp", below where I
> > include the template-implementation-headers (and the moc-generated file
> > would no longer be compiled separately).  However, I'm also having
> trouble
> > getting that into my workflow (*.pro ==>moc==> *.vcproj).
> >
> > Does anyone have suggestions, or a tutorial somewhere on how to do this?
>
> Are you saying that, with the #include, the generated vcproj file does not
> compile as nmake would on the command-line?
>

I misunderstood (or forgot) the old-workflow:  Doing an
#include"moc_MyClass.cpp" in the bottom of my "MyClass.cpp" was all I
needed to get qmake to generate the proper "VCPROJ" that does not compile
the "moc_MyClass.cpp" separately.

(I couldn't find documentation to explicitly "suppress"
separate-compilation of the "moc_MyClass.cpp", but the "#include" was all I
needed.)

Thanks!

--charley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130130/c741f003/attachment.html>


More information about the Interest mailing list