Hi, how did you try to build this? Did you use qmake, plain make, cmake, ...?
However, I think you do need a constructor for classes that are processed by moc - at least it is good style to provide one. One like this would be sufficient: C++-98: NewTest(){} C++-11: NewTest()=default; Also, it is bad style to declare moc'ed classes in the CPP file. Please use headers for this. If it is a private class (one only used inside this one module) the convention is to name the header with _p.h, e.g. NewTest_p.h, this way other programmers in the team know they are not supposed to #include this header without asking first. Konrad On Mon, May 19, 2014 13:17, Graham Labdon wrote: > Hi > > If I declare a class in a cpp file - > #include <QObject> > > class NewTest : public QObject > { > Q_OBJECT > > private slots: > void s1(); > }; > > void NewTest::s1() > { > > } > > #include "NewTest.moc" > > The moc compiler is not invoked > However, if I declare a constructor for NewTest it is > > Can anyone explain why this is? > > I am writing some unit tests and do not need the constructor. > > Once the moc has been invoked I can remove the constructor and then > everything works as expected > > Thanks > _______________________________________________ > Interest mailing list > Interest@qt-project.org > http://lists.qt-project.org/mailman/listinfo/interest > _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest