QT之QCustomPlot的使用(二)--实时曲线
2018-01-23 10:46
302 查看
首先,我们先进行的是以时间为依据来进行动态展示,下面的代码是完整的可以进行使用;
//动态显示的功能 for (int i = 0; i < 10; i++) { num[i] = 0; } n = 0; QTimer *timer = new QTimer; timer->start(500); connect(timer, SIGNAL(timeout()), this, SLOT(Graph_Show()));
void Graph_Show() { QTime t; t = QTime::currentTime(); qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime())); n = qrand() % 50; for (int i = 0; i < 9; i++) { num[i] = num[i + 1]; } num[9] = n; for (int i = 0; i < 10; i++) { temp[i] = i; temp1[i] = num[i]; } m_pCustomPlot = new QCustomPlot(this);//初始化曲线图 m_pCustomPlot->setGeometry(1, 1, 400, 300);//初始化曲线图坐标 m_pCustomPlot->setLocale(QLocale(QLocale::Chinese, QLocale::China)); m_pCustomPlot->addGraph(); m_pCustomPlot->graph(0)->setLineStyle(QCPGraph::lsLine); m_pCustomPlot->graph(0)->setPen(QPen(QColor(0, 0, 255, 200))); m_pCustomPlot->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5)); m_pCustomPlot->graph(0)->setData(temp, temp1); m_pCustomPlot->addGraph(); m_pCustomPlot->graph(1)->setPen(QPen(Qt::red)); m_pCustomPlot->graph(1)->setLineStyle(QCPGraph::lsNone); m_pCustomPlot->graph(1)->setScatterStyle(QCPScatterStyle::ssDisc); m_pCustomPlot->graph(1)->setData(temp, temp1); m_pCustomPlot->xAxis->setTickLabelFont(QFont(QFont().family(), 8)); m_pCustomPlot->yAxis->setTickLabelFont(QFont(QFont().family(), 8)); m_pCustomPlot->xAxis->setLabel(“v”); m_pCustomPlot->yAxis->setLabel(“mV”); m_pCustomPlot->xAxis->setRange(0, 10); m_pCustomPlot->yAxis->setRange(-50, 50); m_pCustomPlot->xAxis2->setVisible(false); m_pCustomPlot->yAxis2->setVisible(false); m_pCustomPlot->xAxis2->setTicks(false); m_pCustomPlot->yAxis2->setTicks(false); m_pCustomPlot->xAxis2->setTickLabels(false); m_pCustomPlot->yAxis2->setTickLabels(false); m_pCustomPlot->replot(); }
相关文章推荐
- QT5使用QCustomPlot绘制实时曲线
- QT绘制曲线图 QCustomplot 的简单使用手册
- QT之QCustomPlot的使用(三)--往X轴添加字符串的静态曲线
- QT下使用QCustomPlot绘制曲线
- Qt5_QCustomPlot画实时动态曲线(1)
- QT之QCustomPlot实现曲线图,附带离子色谱仪项目
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- QT使用QCustomPlot 绘制柱状图
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- QT利用QCustomPlot绘制曲线图
- 转:qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- [转] QT超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- QCustomPlot实现实时动态曲线
- Qt-Qcustomplot设置并使用双重坐标轴(刻度不同的X、Y轴)
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程
- qt超强精美绘图控件 - QCustomPlot一览 及 安装使用教程