I don't wish to start new thread for this small question:
I have the source code tree of existing project, where every .cpp file for class, inherited from QObject, ends with inclusion of "class_name.moc" file.
I try to make the Qt project file to use with QtCreator for this sources.
The problem is in that qmake generates makefile, where *.cpp file depends on corresponding *.moc file, but the *,moc file rules only generated for *.cpp, wich declares private classes, inherited from QObject.
Is it possible to generate makefile with rules to make *.moc files for every *.cpp with *.moc inclusion?
Example:
class1.h
#include <qt4/QtCore/QObject>
{
Q_OBJECT
public:
Class1();
};
#include <qt4/QtCore/QObject>
class Class1 : public QObject
{
Q_OBJECT
public:
Class1();
};
To copy to clipboard, switch view to plain text mode
class1.cpp
#include "class1.h"
Class1::Class1()
{
}
#include "class1.moc"
#include "class1.h"
Class1::Class1()
{
}
#include "class1.moc"
To copy to clipboard, switch view to plain text mode
class1.pro
TEMPLATE = lib
INCLUDEPATH += .
HEADERS += class1.h
SOURCES += class1.cpp
TEMPLATE = lib
INCLUDEPATH += .
HEADERS += class1.h
SOURCES += class1.cpp
To copy to clipboard, switch view to plain text mode
qmake
make
...
No rule to make target `class1.moc', needed by `class1.o'.
But if cpp will be modified:
class1.cpp
#include "class1.h"
{
Q_OBJECT
};
Class1::Class1()
{
}
#include "class1.moc"
#include "class1.h"
class Private : public QObject
{
Q_OBJECT
};
Class1::Class1()
{
}
#include "class1.moc"
To copy to clipboard, switch view to plain text mode
then lib is generated correctly.
Bookmarks