源文件
#include "mainwindowh"
#include "ui_mainwindowh"
#include "cwidgetcheckboxh"
#include <QDebug>
MainWindow::MainWindow(QWidget parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
m_pPlot = new QCustomPlot;
m_pPlot->setInteractions(QCP::iRangeDrag|QCP::iRangeZoom|QCP::iMultiSelect|QCP::iSelectOther|QCP::iSelectItems);
m_pPlot->axisRect()->setupFullAxesBox();
m_pPlot->xAxis->setLabel("时间");
m_pPlot->yAxis->setLabel("值");
m_pPlot->xAxis->setRange(0,30);
m_pPlot->yAxis->setRange(0,100);
m_pPlot->legend->setVisible(true);
//m_pPlot->graph( index )->setName(QString::fromStdString(nameVec[0][0]));
ui->verticalLayout->addWidget( m_pPlot );
m_id = startTimer(10);
m_line = m_pPlot->addGraph();
m_line->setName( tr("test") );
m_line->setPen(QPen(QColor(255,0,0)));
m_line->setScatterStyle(QCPScatterStyle::ssDisc);
m_index = 0;
}
MainWindow::~MainWindow()
{
delete ui;
}
double MainWindow::getData(double time)
{
double s = qCos( time M_PI 2 ) ;
return s;
}
void MainWindow::timerEvent(QTimerEvent event)
{
int data = qrand()%20;
m_line->addData(m_index, data);
//m_line->addData(vecX,m_vetData);
m_pPlot->replot();
m_index++;
if( m_index > 31 )
{
m_pPlot->xAxis->setRange(m_index-30,m_index);
}
QMainWindow::timerEvent(event);
}
头文件
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "qcustomploth"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget parent = 0);
~MainWindow();
double getData(double time);
protected:
void timerEvent(QTimerEvent event) Q_DECL_OVERRIDE;
//void timerEvent(QTimerEvent event);
private slots:
private:
Ui::MainWindow ui;
QCPGraph m_line;
QCustomPlot m_pPlot;
QVector m_vetData;
int m_index;
int m_id;
};
#endif // MAINWINDOW_H
工业工程写论文没有数据需要添加数据。
论文数据的获取是:
一、工具
getdat
PPT
Excel
二、步骤 (PPT步骤)
1)截一张放在PPT中
2)PPT -》插入-》形状-》曲线-》勾勒图像曲线的点
3)勾勒的曲线不太重合时,点击曲线,鼠标右键点击编辑顶点,然后不断调整
4)在形状中拖一个矩形,把原图覆盖,填充设为白色,置于下一层
5)复制这页PPT,选择性粘贴,选择增强型图元文件
6)将这幅另存为jpg格式
三、getdata步骤
1)file-》open image
2)设置坐标系(set the scale):设置横坐标/纵坐标的最大最小值
3)选择区域(digitize area):框处区域
4)如果不出数据,可能是描的线没有被识别到,在PPT中重新加一个轮廓
5)将数据复制到Excel中,在Excel中生成图像
以上就是关于Qt 使用 qcustomplot 绘制曲线例子全部的内容,包括:Qt 使用 qcustomplot 绘制曲线例子、工业工程写论文没有数据怎么办、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)