我正在继承 QwtPlot 。我有以下错误:
moc_myplot.obj:-1:错误:LNK2001:未解析的外部符号“public:static struct QMetaObject const QwtPlot :: staticMetaObject”(?staticMetaObject @ QwtPlot @@ 2UQMetaObject @@ B) 我试过以下的事情:运行qmake,rebuild,clean,删除debug文件夹,重新编译qwt库。这没有用。这是最小的代码: myplot.h:
#ifndef MYPLOT_H
#define MYPLOT_H
#include <QObject>
#include <qwt_plot.h>
class MyPlot : public QwtPlot
{
Q_OBJECT
public:
MyPlot();
};
#endif // MYPLOT_H
myplot.cpp:
#include "myplot.h"
MyPlot::MyPlot()
{
}
这是 .pro 文件:
#-------------------------------------------------
#
# Project created by QtCreator 2015-06-22T19:33:24
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = MyPlot
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
myplot.cpp
HEADERS += mainwindow.h \
myplot.h
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../qwt-6.1.2/lib/ -lqwt
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../qwt-6.1.2/lib/ -lqwtd
else:unix: LIBS += -L$$PWD/../../../../../qwt-6.1.2/lib/ -lqwt
INCLUDEPATH += $$PWD/../../../../../qwt-6.1.2/include
DEPENDPATH += $$PWD/../../../../../qwt-6.1.2/include
我正在使用Qt Creator 3.4.1基于Qt 5.4.2(MSVC 2013,32位)。套件:桌面Qt 5.4.2 MSVC2013 64位。编译器: Microsof Visual C ++编译器12.0(amd64)。如果我在Q_OBJECT
中评论myplot.h
宏,一切正常。我可以在不进行子类化的情况下使用qwt_plot
,以便this->setCentralWidget(new QwtPlot());
中的mainwindow.cpp
行可以。