Unresolved external symbol "public: virtual struct QMetaObject const * __thiscall Parent

后端 未结 23 2305
醉话见心
醉话见心 2020-11-30 21:33

I inherited a class from QObject :

class Parent: public QObject
{
    Q_OBJECT
    QObject* cl;

public:
    Parent(QObject *parent=0):QObject(parent) {
            


        
23条回答
  •  無奈伤痛
    2020-11-30 22:30

    So the issue was I needed the Qt MOC compiler to compile my .h file. This is required for any classes that extend QObject or one of its children. The fix involed (for me) right-clicking on the header file, choosing Properties, and setting the Item Type to "Qt MOC Input", then hitting "Compile" on the header, and then adding the resulting moc_myfilename.cpp file to my project.

提交回复
热议问题