QWidget: Must construct a QApplication before a QPaintDevice怎么破?

月半不知愁 2017-09-27 05:05:22
使用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
...全文
1319 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
AgentNeo 2017-12-07
  • 打赏
  • 举报
回复
我的是因为没有使用管理员权限打开。。。
AgentNeo 2017-12-05
  • 打赏
  • 举报
回复
楼主搞定了吗

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧