Search code examples
qtqt5qmakemoc

What's the difference between <CLASS>.moc and moc_<CLASS>.cpp


Most of my classes generate a moc_<CLASS>.cpp file. Why do some classes generate a <CLASS>.moc file instead of/as well as?


Solution

  • <CLASS>.moc is generated wherever there is a need to MOC the source file as well as/instead of the header (i.e. if the Q_OBJECT macro is used in the source).

    See this answer for how this can be achieved.