PDA

View Full Version : Inheriting QwtPlot and Q_OBJECT



gpsgek
29th March 2010, 11:10
Dear all,

I'm trying to inherite QwtPlot and using signals/slots. So, my header file looks like:

#pragma once
#include "qwt_plot.h"

#include <QtGui>

class MyQwtCurvePlot :
public QwtPlot
{
Q_OBJECT

public:
MyQwtCurvePlot(QWidget *p = 0);
~MyQwtCurvePlot(void);

public slots:
void highlight(const QVector<QPointF> &pa);
};



But, while compiling this with the Q_OBJECT macro, the compiler (MSVC2008) gives an error, namely:

1>Generating Code...
1>Compiling...
1>moc_MyQwtCurvePlot.cpp
1>Linking...
1> Creating library K:\TEST\Qt\test\Debug\test.lib and object K:\TEST\Qt\test\Debug\test.exp
1>moc_MyQwtCurvePlot.obj : error LNK2001: unresolved external symbol "public: static struct QMetaObject const QwtPlot::staticMetaObject" (?staticMetaObject@QwtPlot@@2UQMetaObject@@B)
1>K:\TEST\Qt\test\Debug\test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://k:\TEST\Qt\test\test\Debug\BuildLog.htm"


Does anyone have an idea where this comes from? The class compiles perfectly with Q_OBJECT removed, but then the signal/slot system doesn't work.

Thanks for replies in advance,

Martijn

dbzhang800
31st March 2010, 01:51
add DEFINES += QWT_DLL to .pro file when you use windows.

nitinkamkar
5th July 2011, 06:09
Add QWT_DLL in project properties->c++->preprocessor->definitions if you are using VS for Qt..