I inherited a class from QObject :
class Parent: public QObject
{
Q_OBJECT
QObject* cl;
public:
Parent(QObject *parent=0):QObject(parent) {
Faced this issue in case of chained CMake targets. Turned out I had to enable CMAKE_AUTOMOC
even in targets that didn't use Qt directly (transitively). Also turned out that CMAKE_AUTOMOC
can't be used w/o find_package(QtX)
in same CMakeLists.txt
or CMakeLists.txt
of parent.
In my case, none of the above worked but it was totally my mistake.
I had overrided virtual functions in .h file (declared them) but had never defined them in .cpp :)
This happened to me recently when switching from MingW to MSVC. I had a prototyped class/struct listed as a class, and MingW didn't mind.
MSVC definitely sees a difference between class
and struct
when prototyping is concerned.
Hope that helps someone else one day.
Either answer works for me in the VS 2013 environment. I eventually solve the problem by removing the .h/.cpp from project, and adding it back.
I am working in VS2015 with an integrated Perforce p4v client. In my case Perforce tried to add moc file to a depo, when I reverted this operation, Perforce removed this moc file from project and deleted it. The file was recreated after the next compilation, but it wasn't included in project, I have to add it manually to Generated files, when I finally understood what was the problem.