我正在使用 QtCharts 来显示模拟数据。模拟从零时间开始,但我的图表轴似乎总是从 19 小时开始。这让我很困惑。图表的设置很简单:
std::vector<SimData> data;
// ... Populate data
auto series = new QLineSeries();
for(auto i : data)
{
// Append time in milliseconds and a value
series->append(i.msTime, i.value);
}
this->legend()->hide();
this->addSeries(series);
this->axisX = new QDateTimeAxis;
this->axisX->setTickCount(10);
this->axisX->setFormat("HH:mm:ss");
this->axisX->setTitleText("Sim Time");
this->axisX->setMin(QDateTime());
this->addAxis(this->axisX, Qt::AlignBottom);
series->attachAxis(this->axisX);
this->axisY = new QValueAxis;
this->axisY->setLabelFormat("%i");
this->axisY->setTitleText(x->getID().c_str());
this->addAxis(this->axisY, Qt::AlignLeft);
series->attachAxis(this->axisY);
如果我在没有数据的情况下运行,但只显示图表,我会得到:
如果我添加数据,从时间 0 开始,数据总量是正确的,但时间仍然从 19:00:00 开始。为什么时间不是从 00:00:00 开始?