"Fanda Vacek" <fanda.vacek@xxxxxxxx> wrote in message
news:op.tc83fecjasg76k@xxxxxxxxxxxxxxxxxxxxxxxx
The QT4 documnetation does not tell a much about (QT3 doc does). I've
found only this in a moc chapter.
For Q_OBJECT class declarations in implementation (.cpp) files, we
suggest a makefile rule like this:
foo.o: foo.moc
foo.moc: foo.cpp
moc $(DEFINES) $(INCPATH) -i $< -o $@
This guarantees that make will run the moc before it compiles foo.cpp.
You can then put
#include "foo.moc"
at the end of foo.cpp, where all the classes declared in that file are
fully known.
After some playing and inspecting QT4 sources, I've found that I have to
include 2 files 'sourcename.moc' and 'moc_sourcename.cpp' at the end of
'sourcename.cpp', but I still do not know why.
Fanda
You only have to #include the .moc file. The moc_*.cpp file can be
compiled as a separate compilation unit, where as the .moc file cannot
(the declaration of the class that the .moc file implements is not
available).
This is really all the same as in Qt 3.
Volker