Q_Object in class inherited by QwtPlot - Undefined Reference
Hi to all,
I have some very strange problems.
I would like to add the Q_OBJECT macro to a class called Plot, inherited by QwtPlot.
I did everything in the right way and if I replace QwtPlot by QObject it works.
If I inherit by QwtPlot I get an "Undefined reference" error by the linker, it complains about missing QMetaObject const QwtPlot::staticMetaObject ...
The .pro file is:
Code:
#-------------------------------------------------
#
# Project created by QtCreator 2017-03-08T16:00:42
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = Test
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp \
plot.cpp
HEADERS += mainwindow.h \
plot.h
FORMS += mainwindow.ui
INCLUDEPATH += C:\Qwt-6.1.3\include
LIBS += -LC:\Qwt-6.1.3\lib\ -lqwt
The plot.h is:
Code:
#ifndef PLOT_H
#define PLOT_H
#include <QObject>
#include <qwt_plot.h>
{
Q_OBJECT
public:
};
#endif // PLOT_H
Funny thing is that they do it in pretty much the same way in the examples of Qwt.
Does anyone know how to solve this problem, please? :(
Thanks a lot.
Re: Q_Object in class inherited by QwtPlot - Undefined Reference
Quote:
LIBS += -LC:\Qwt-6.1.3\lib\ -lqwt
Are you trying to link a debug mode app with a release mode Qwt or vice-versa? When you derive from QObject, qmake will link everything to the right Qt libraries depending on whether you are building in debug or release mode, but I am not sure what happens in the case of linking to Qwt. It may depend on whether you have built Qwt with the right options.
Re: Q_Object in class inherited by QwtPlot - Undefined Reference
After many hours I found out that I need to append
in my project file.
I don't know why I have to do this but it works.
Thanks. :)