qt5 customplot 时间轴显示

hellomeier 2017-03-11 01:20:33
哪位大神帮忙解决一下 qcustomplot 图形显示的时候时间轴异常

QBrush backRole;
backRole.setColor("skyblue");
backRole.setStyle(Qt::SolidPattern);
ui->customPlot->setBackground(backRole);
ui->customPlot->xAxis->setLabel("time");
ui->customPlot->yAxis->setLabel("value");//坐标轴名称
ui->customPlot->xAxis->setLabelColor("red");//坐标轴名称颜色
ui->customPlot->yAxis->setLabelColor("red");
ui->customPlot->xAxis->setTickLabelColor(QColor("green"));//坐标轴颜色
ui->customPlot->yAxis->setTickLabelColor(QColor("green"));
ui->customPlot->xAxis->setTickLabelRotation(-40);//坐标轴倾斜角

long long int max_time,min_time,max_value,min_value;
min_time = 20170101011234;//年月日 时:分:秒
max_time = 20170228235959;
ui->customPlot->xAxis->setRange(min_time, max_time);
ui->customPlot->yAxis->setRange(min_value, max_value);
QSharedPointer<QCPAxisTickerDateTime> dateTicker(new QCPAxisTickerDateTime);
dateTicker->setDateTimeFormat("yyyy-MM-dd hh:mm:ss");
ui->customPlot->xAxis->setTicker(dateTicker);

图片传不上来,这是图片地址
https://user.qzone.qq.com/1137462397/main
...全文
916 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
hellomeier 2017-03-20
  • 打赏
  • 举报
回复
获取当前时间到1970,1,1的秒数 ui->customPlot->xAxis->setRange(秒数1, 秒数1);

16,213

社区成员

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

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