I'm trying to compile the basic tutorial program at http://doc.trolltech.com/4.4/mainwindows-application.html and running into a problem.
Doing things the way the tutorial program does them, gives a compile error:
In file included from debug\moc_mainwindow.cpp:10:
debug\../mainwindow.h:2: error: expected class-name before '{' token
debug\../mainwindow.h:5: error: ISO C++ forbids declaration of `Q_OBJECT' with no type
The problem is the need for
#include <QtGui>
The tutorial program puts this in mainwindow.cpp which is the desirable way to do it, but then it doesn't get copied into the moc file.
If I put it into mainwindow.h instead, everything works fine, but doing that in every header file is inelegant and will extend compile times once the program gets large.
Is this something that changed since the tutorial was written? (I'm using the latest Qt 4.5.3, Windows SDK install, compiling from the command line.) Am I missing something, or is there any known fix for this problem?