Why does this Qt header file fail to get parsed by moc?
I created a new 'C++ library' project in Qt, which has the following header file:
#include "Test_global.h"
#includ开发者_运维百科e <QString>
#include <QTcpServer>
class TESTSHARED_EXPORT Test : QTcpServer
{
Q_OJECT
public:
Test();
~Test();
signals:
void NewMessage(QString);
};
(The implementation file is basically empty.)
When I try to build the object, I get errors:
Test.h:8: error: ISO C++ forbids declaration of ‘Q_OJECT’ with no type Test.h:10: error: expected ‘;’ before ‘public’ Test.cpp:3: error: definition of implicitly-declared 'Test::Test()'
So it looks like moc
isn't processing the file at all. What have I done wrong?
It should be Q_OBJECT
, not Q_OJECT
.
精彩评论