Link Error By Q_OBJECT
Solved
General and Desktop
-
EvaluateWidget .h
#ifndef EVALUATEWIDGET_H #define EVALUATEWIDGET_H #include <QtTreePropertyBrowser> class EvaluateWidget : public QtTreePropertyBrowser { Q_OBJECT public: EvaluateWidget(QWidget * parent = 0); }; #endif // EVALUATEWIDGET_H
EvaluateWidget .cpp
#include "EvaluateWidget.h" EvaluateWidget::EvaluateWidget(QWidget * parent) : QtTreePropertyBrowser(parent) { }
Link error:
moc_EvaluateWidget.obj:-1: error: LNK2001: unresolved external symbol "public: static struct QMetaObject const QtTreePropertyBrowser::staticMetaObject" (?staticMetaObject@QtTreePropertyBrowser@@2UQMetaObject@@B)
Env:
Desktop_Qt_5_9_1_MSVC2017_64bit Qt Creator 4.3.1
If
Q_OBJECT
is removed, everything is OK.
Any way to solve the problem? -
@jronald said in Link Error By Q_OBJECT:
LNK2001: unresolved external symbol "public: static struct QMetaObject
Hi
Step one is to delete the build folder and rebuild
if that dont help then, remove Q_OBJECT and add it againAlso check the moc_* files are being generated.
-
Hi, googling "unresolved external symbol "public: static struct QMetaObject const QtTreePropertyBrowser" returns this 7 year old bug
At the end it says adding the symbolQT_QTPROPERTYBROWSER_IMPORT
to your build environment should help.