qcustomplot绘图的问题

大神收下我的膝盖吧 2016-01-05 03:09:39
我有一个获取数据(电压)的函数:getData(),这个函数是每一毫秒就获取一次,然后在lineEdit中显示出来。我用的是qcustomplot控件,但是我只需要绘制一定的时间(比如说7分钟),并不需要一直动态的绘制。看了qcustomplot官网动态绘制曲线的例子,上边是把横坐标左移了,这就会造成一个问题,就是前面一部分的图被刷新掉了,而我需要看到的是整个7分钟的图像,然后再对其进行处理。请问我该如何处理?或者是有没有方法只让曲线动,而不是坐标轴动的?万分感谢!!
...全文
401 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
引用 5 楼 ch2065 的回复:
[quote=引用 4 楼 Fanko777 的回复:] [quote=引用 2 楼 ch2065 的回复:] 你可以看例子上, ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight); 这句设置x轴显示范围。
大哥,可否解释下ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight);setRange中的3个参数啊[/quote] 这个你可以按F2进入函数实现,一看就知道是什么意思了。 /*! \overload Sets the range of the axis. The \a position coordinate indicates together with the \a alignment parameter, where the new range will be positioned. \a size defines the size of the new axis range. \a alignment may be Qt::AlignLeft, Qt::AlignRight or Qt::AlignCenter. This will cause the left border, right border, or center of the range to be aligned with \a position. Any other values of \a alignment will default to Qt::AlignCenter. */ void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment) { if (alignment == Qt::AlignLeft) setRange(position, position+size); else if (alignment == Qt::AlignRight) setRange(position-size, position); else // alignment == Qt::AlignCenter setRange(position-size/2.0, position+size/2.0); } 可以看懂英文吧。。[/quote] 明白了,谢谢了!大哥,方便加个qq好友不,584321028.
ch2065 2016-01-08
  • 打赏
  • 举报
回复
引用 4 楼 Fanko777 的回复:
[quote=引用 2 楼 ch2065 的回复:] 你可以看例子上, ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight); 这句设置x轴显示范围。
大哥,可否解释下ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight);setRange中的3个参数啊[/quote] 这个你可以按F2进入函数实现,一看就知道是什么意思了。 /*! \overload Sets the range of the axis. The \a position coordinate indicates together with the \a alignment parameter, where the new range will be positioned. \a size defines the size of the new axis range. \a alignment may be Qt::AlignLeft, Qt::AlignRight or Qt::AlignCenter. This will cause the left border, right border, or center of the range to be aligned with \a position. Any other values of \a alignment will default to Qt::AlignCenter. */ void QCPAxis::setRange(double position, double size, Qt::AlignmentFlag alignment) { if (alignment == Qt::AlignLeft) setRange(position, position+size); else if (alignment == Qt::AlignRight) setRange(position-size, position); else // alignment == Qt::AlignCenter setRange(position-size/2.0, position+size/2.0); } 可以看懂英文吧。。
  • 打赏
  • 举报
回复
引用 2 楼 ch2065 的回复:
你可以看例子上, ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight); 这句设置x轴显示范围。
大哥,可否解释下ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight);setRange中的3个参数啊
  • 打赏
  • 举报
回复
引用 2 楼 ch2065 的回复:
你可以看例子上, ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight); 这句设置x轴显示范围。
好的,我看看。万分感谢!!
ch2065 2016-01-07
  • 打赏
  • 举报
回复
你可以看例子上, ui->customPlot->xAxis->setRange(key+0.25, 8, Qt::AlignRight); 这句设置x轴显示范围。
  • 打赏
  • 举报
回复
求高手赐教

16,213

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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