PDA

View Full Version : QWT in QT: displaying qwt plot as widget on mainwindow



zaidi1212
12th June 2013, 13:00
Hello all,

I have developed a code for plotting sine wave in qwt.I have made a subclass of QWT with the name of plot. I want to show this plot as widget in mainwindow. I did following in Mainwindow.cpp:



dplot = new plot(this );
const int margin = 4;
dplot->setContentsMargins( margin, margin, margin, margin );

setCentralWidget( dplot );

and in Mainwindow.h I have declared the class plot like this:



#include <QMainWindow>

class plot;

class MainWindow: public QMainWindow
{
Q_OBJECT
public:
MainWindow();

private Q_SLOTS:


private:


private:
plot *dplot;

};


I am facing following error after compiling:

In constructor 'MainWindow::MainWindow()':
error: no matching function for call to 'plot::plot(MainWindow* const)'
candidates are: plot::plot()
plot::plot(const plot&)

Please help me.

MSUdom5
12th June 2013, 16:10
In your derived class, you need a constructor that take a QWidget pointer argument. This constructor needs to call with the QwtPlot constructor with the same pointer. Something like



plot::plot(QWidget* parent) : QwtPlot(parent) {

}