Is it possible to tell the Qt MOC that I would like to declare the class and implement it in a single file rather than splitting them up into an .h and .cpp file?
If you want to declare and implement a QObject subclass in you cpp file, you have to manually include the moc file.
For example: (file main.cpp)
struct SubObject : QObject
{
Q_OBJECT
};
//...
#include "main.moc"
You have to rerun moc (make qmake
) after adding the #include
statement.