A simple Plot doesn't work in Qt5
Hi,
A simple Plot doesn't work in Qt5. Please, help me!
SimplePlotInQt5.pro
Code:
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
SOURCES += \
main.cpp \
plotwindow.cpp
HEADERS += \
plotwindow.h
QWT_LOCATION = c:/Qwt-6.1.0
INCLUDEPATH += $${QWT_LOCATION}/include
LIBS = -L$${QWT_LOCATION}/lib \
-lqwt
plotwindow.h
Code:
#ifndef PLOTHWINDOW_H
#define PLOTWINDOW_H
#include <QMainWindow>
{
Q_OBJECT
public:
explicit PlotWindow
(QWidget *parent
= 0);
signals:
public slots:
};
#endif // PLOTWINDOW_H
plotwindow.cpp
Code:
#include "plotwindow.h"
#include <qwt_plot.h>
#include <qwt_legend.h>
#include <qwt_plot_grid.h>
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
#include <QHBoxLayout>
#include <QWidget>
PlotWindow
::PlotWindow(QWidget *parent
) :{
plot->setTitle(tr("Simple Plot"));
plot->setCanvasBackground(Qt::white);
plot
->setAxisScale
(QwtPlot::yLeft,
0.0,
100);
grid->attach(plot);
curve->setTitle(tr("Points"));
curve
->setPen
(QPen(Qt
::blue,
4));
curve
->setRenderHint
(QwtPlotItem::RenderAntialiased,
true);
curve->setSymbol(symbol);
curve->setSamples(points);
curve->attach(plot);
mainLayout->addWidget(plot);
window->setLayout(mainLayout);
setCentralWidget(window);
this->setWindowTitle(tr("Simple Plot"));
this->resize(600, 400);
}
main.cpp
Code:
#include <QApplication>
#include "plotwindow.h"
int main(int argc, char **argv)
{
PlotWindow gw;
gw.show();
return app.exec();
}
Output
Quote:
QWidget: Must construct a QApplication before a QPaintDevice
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
Re: A simple Plot doesn't work in Qt5
Looks like you are using the release version of the lib in a debug app
In the pro file try
LIBS += -L$${QWT_LOCATION}/lib -lqwtd
note the -lqwtd instead of -lqwt
Re: A simple Plot doesn't work in Qt5
Quote:
Originally Posted by
Cah
Looks like you are using the release version of the lib in a debug app
In the pro file try
LIBS += -L$${QWT_LOCATION}/lib -lqwtd
note the -lqwtd instead of -lqwt
Yes, It works! Thank you very much :D
Re: A simple Plot doesn't work in Qt5