我想以 hh:mm:ss 格式显示我的 x 轴。它基本上可以工作,但是有一个问题。显示的时间不是从 00:00:00 开始,而是从 01:00:00 开始。我想可能是因为时间处于 ap 模式,但我没有具体说明,我是这样做的:
customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
customPlot->xAxis->setDateTimeFormat("hh:mm:ss");
并且点 0 的情节从 1 小时开始:
对于这方面的所有帮助,我将不胜感激。如何让起点0显示为00:00:00?
最佳答案
使用 HH
(或 H
来避免前导零)。小写的 h
是 AM/PM 小时格式,从 1 开始计数。
字体:http://doc.qt.io/qt-5/qdatetime.html#toString
如果问题仍然存在,应该是时区问题。添加
customPlot->xAxis->setDateTimeSpec(Qt::UTC)
在 SetTimeFormat
之前
关于c++ - setDateTimeFormat 增加一个小时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31093640/