setDateTimeFormat添加一个小时 [英] setDateTimeFormat adds an hour

查看:843
本文介绍了setDateTimeFormat添加一个小时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想以hh:mm:ss格式显示我的x轴。它basicaly工程,但有一个问题。显示的时间不从00:00:00开始,而是从01:00:00开始。我认为也许是因为时间是在ap模式,但我没有指定,这里是如何做:

I would like to display my x axis in the hh:mm:ss format. It basicaly works, but there is one problem. The displayed time doesnt start from 00:00:00 but from 01:00:00. I thought maybe its because the time is in ap mode, but I havent specified that, here is how I do it:

customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
customPlot->xAxis->setDateTimeFormat("hh:mm:ss");

点0处的绘图从小时1开始:

And the plot at point 0 starts from hour 1:

>

我会感谢所有关于这一点的帮助。

I would appreciate all help regarding this. How to make the starting point 0 shown as 00:00:00?

推荐答案

使用 HH (或 H ,以避免前导零)。小写 h 是AM / PM小时格式,从1开始计数。

Use HH (or H to avoid the leading zero). Lowercase h is for AM/PM hour format, which starts to count from 1.

字体: http://doc.qt.io/qt-5/qdatetime.html#toString

如果问题仍然存在,应该与时区相关。添加

If the problem still persists, it should be timezone related. Add

customPlot-> xAxis-> setDateTimeSpec(Qt :: UTC)

之前 SetTimeFormat

这篇关于setDateTimeFormat添加一个小时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆