我正在继承 QwtPlot。我有以下错误:
moc_myplot.obj:-1:错误:LNK2001:无法解析的外部符号“公用:静态结构QMetaObject常量QwtPlot :: staticMetaObject”(staticMetaObject @ QwtPlot @@ 2UQMetaObject @@ B') 我曾尝试以下操作:运行QMAKE,重建,清理,删除调试文件夹,重新编译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
Run Code Online (Sandbox Code Playgroud)
myplot.cpp:
#include "myplot.h"
MyPlot::MyPlot()
{
}
Run Code Online (Sandbox Code Playgroud)
这是.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
Run Code Online (Sandbox Code Playgroud)
我正在使用基于 Qt 5.4.2(MSVC 2013,32 位)的 Qt Creator 3.4.1。套件:桌面 Qt 5.4.2 MSVC2013 64 位。编译器:Microsof Visual C++ 编译器 12.0(amd64)。如果我Q_OBJECT在myplot.h一切中评论宏就可以了。我可以在qwt_plot没有子类化的情况下使用,所以输入this->setCentralWidget(new QwtPlot());行就mainwindow.cpp可以了。
| 归档时间: |
|
| 查看次数: |
1422 次 |
| 最近记录: |