Hello all,
I am using qwt 6.0.0 with Qt 4.6.2 and I am getting the error "QWidget: Must construct a QApplication before a QPaintDevice." I searched the forum and see that other users have had similar error and the replies suggested are 1. debug/release compilation modes 2. static/dynamic library. I have tried these options suggested in the forum but I am not able to get rid of this error. In my case either in debug or release mode, I get the same error. My code is very simple - plotting a sine plot using qwt:
#include <iostream>
#include <fstream>
#include <string>
#include <QApplication>
#include <QDialog>
#include <QPushButton>
#include <QString>
#include <QFileInfo>
#include <QMainWindow>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QwtPlot plot(QwtText("CppQwtExample1"));
plot.setGeometry(0,0,640,400);
plot.setAxisScale(QwtPlot::xBottom, 0.0,2.0 * M_PI);
plot.setAxisScale(QwtPlot::yLeft,-1.0,1.0);
QwtPlotCurve sine101;
std::vector<double> xs;
std::vector<double> ys;
for (double x1 = 0; x1 < 2.0 * M_PI; x1+=(M_PI / 10.0))
{
xs.push_back(x1);
ys.push_back(std::sin(x1));
}
sine101.setSamples(&xs[0],&ys[0],xs.size());
sine101.attach(&plot);
plot.show();
return app.exec();
}
Any help will be appreciated.
Thanks.
Bookmarks