因此,我试图在qcustomplot的x轴上绘制时间...我的问题是我如何才能获得x轴的“滴答声”,间隔为一小时(00:00、01:00, 02:00 ...等)。我的代码和结果如下:
码:
ui->diagramArea->yAxis->setLabel("Thermocracy");
ui->diagramArea->yAxis->setRange(35,42);
ui->diagramArea->xAxis->setLabel("Hour of Measurement");
ui->diagramArea->xAxis->setTickLabelType(QCPAxis::ltDateTime);
ui->diagramArea->xAxis->setDateTimeFormat("hh:mm");
ui->diagramArea->xAxis->setRange(-7200,75600); //that's because im gmt+2
ui->diagramArea->xAxis->setAutoTickStep(3600);
ui->diagramArea->addGraph();
ui->diagramArea->graph(0)->setBrush(QBrush(QColor(204,243,255)));
ui->diagramArea->graph(0)->setPen(pen);
ui->diagramArea->graph(0)->setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssDisc, 5));
ui->diagramArea->graph(0)->setData(vTime,vData);
ui->diagramArea->replot();
结果:
最佳答案
尝试使用void QCPAxis::setTickStep ( double step)
ui->diagramArea->xAxis->setAutoTickStep(false);
ui->diagramArea->xAxis->setTickStep(3600);
http://www.qcustomplot.com/documentation/classQCPAxis.html#a99fe77b034e06f5b723995beab96e741
它需要bool变量,因此您似乎设置了自动计算的步骤。