Perché questo file di intestazione Qt non riescono a ottenere analizzato da moc?
-
13-10-2019 - |
Domanda
Ho creato un nuovo progetto 'C ++ library' in Qt, che ha il seguente file di intestazione:
#include "Test_global.h"
#include <QString>
#include <QTcpServer>
class TESTSHARED_EXPORT Test : QTcpServer
{
Q_OJECT
public:
Test();
~Test();
signals:
void NewMessage(QString);
};
(Il file di implementazione è praticamente vuoto.)
Quando provo a costruire l'oggetto, ricevo un errore:
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()'
Quindi sembra moc
non sta elaborando il file a tutti. Che ho io torto fatto?
Soluzione
Dovrebbe essere Q_OBJECT
, non Q_OJECT
.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow