I am trying to build the example from documentation, but it fails:
#include <QtCore>
#include <iostream>
using namespace std;
{
Q_OBJECT
Q_PROPERTY(Priority priority READ priority WRITE setPriority)
Q_ENUMS(Priority)
public:
{
};
~MyClass()
{
cout << "MyClass Destructor"<<endl;
};
enum Priority { High, Low, VeryHigh, VeryLow };
void setPriority(Priority priority);
Priority priority() const;
};
int main(int argc, char *argv[])
{
MyClass megaInst;
return a.exec();
}
#include <QtCore>
#include <iostream>
using namespace std;
class MyClass : public QObject
{
Q_OBJECT
Q_PROPERTY(Priority priority READ priority WRITE setPriority)
Q_ENUMS(Priority)
public:
MyClass(QObject *parent = 0)
:QObject(parent)
{
};
~MyClass()
{
cout << "MyClass Destructor"<<endl;
};
enum Priority { High, Low, VeryHigh, VeryLow };
void setPriority(Priority priority);
Priority priority() const;
};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
MyClass megaInst;
return a.exec();
}
To copy to clipboard, switch view to plain text mode
My VS writes me:
1>main.obj : error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall MyClass::metaObject(void)const " (?metaObject@MyClass@@UBEPBUQMetaObject@@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual void * __thiscall MyClass::qt_metacast(char const *)" (?qt_metacast@MyClass@@UAEPAXPBD@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual int __thiscall MyClass::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@MyClass@@UAEHW4Call@QMetaObject@@HPA PAX@Z)
How can it be fixed?
Bookmarks