使用Qwt的plot和plotcurve畫出一條曲線,代碼非常簡單,屬性曲線的用法,現在是報錯:longj::InitDll CheckPidProc g_modulename plot.exe bAppOffice 0 return g_pidProcType 0QWidget: Must construct a QApplication before a QPaintDevice
inner:module name : ATTACH_PrintScreen is called!!!empty inner name and ver.Dynamic-----------------screen need SpecialCtrl mon 1
直接貼代碼吧,求高手指導
//main.cpp
#include "mainwindow.h"
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
--------------------------------------------
//mainwindow.cpp
#include "mainwindow.h"
#include <QWT/qwt_plot_curve.h>
#include <QWT/qwt_plot.h>
#include <QPen>
#include <math.h>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
//QWidget *widget =new QWidget;
//this->setCentralWidget(widget);
qwtplot = new QwtPlot(this);
qwtplot->setAxisTitle(QwtPlot::xBottom, "x –>");
qwtplot->setAxisScale(QwtPlot::xBottom,0.0,10.0);//橫坐標從0到10, xBottom表示橫坐標的方向從下往上
qwtplot->setAxisTitle(QwtPlot::yLeft,"y ->");
qwtplot->setAxisScale(QwtPlot::yLeft,-1.0,1.0);//縱坐標-1到1,yLeft表示縱坐標的方向從左到右
//curve->attach(qwtplot);
for (double x = 0; x < 2.0 * M_PI; x+=(M_PI / 10.0))
{
xs.append(x);
ys.append(qSin(x));
}
curve.setSamples(xs,ys);
curve.attach(this->qwtplot);
}
MainWindow::~MainWindow()
{
}
-------------------------------------------
//mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QWidget>
#include <QVector>
#include <QWT/qwt_plot_curve.h>
#include <QWT/qwt_plot.h>
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
private:
QVector<double> xs;
QVector<double> ys;
QwtPlotCurve curve;
QwtPlot *qwtplot;
};
#endif // MAINWINDOW_H
uj5u.com熱心網友回復:
樓主搞定了嗎uj5u.com熱心網友回復:
我的是因為沒有使用管理員權限打開。。。轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/52018.html
上一篇:請問如何改默認邊框顏色?
下一篇:c語言有關素數對問題求大神解答
