someclass.h, someclass_alternative.cpp and auto moc

Friedrich W. H. Kossebau kossebau at
Thu Oct 19 15:13:37 UTC 2017

Am Donnerstag, 19. Oktober 2017, 14:42:10 CEST schrieb René J.V. Bertin:
> On Thursday October 19 2017 14:03:16 Milian Wolff wrote:
> >Are you maybe missing the explicit moc include?
> No, the problem is that there's no way to specify the right moc. Qt imposes
> that it matches the filename (so with the _qtb suffix), but then it won't
> include anything defined in the headerfile if the header doesn't also have
> the _qtb suffix. (Is that clear? =) )

For the record, it is not some "Qt" which imposes this, but CMake's automoc 
and it's primitive "automagic" estimation of header files to be moc'ed:
If an #include statement like #include "moc_foo.cpp" is found, the Q_OBJECT 
class declaration is expected in the header, and moc is run on the header 
where "header" seems hard calculated (missing documentation) by
	header_filename = $moc_filename - "moc_" - SOURCE_EXT + HEADER_EXT

Additionally, header files with the same base name (like foo.h) or _p appended 
to the base name (like foo_p.h) are parsed for Q_OBJECT macros, and if found, 
moc is also executed on those files.



More information about the KDevelop-devel mailing list