Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QCustomPlot display time in HH:MM:SS

I was wondering either it is possible in the QCustomPlot library to change display format of the data on one of the axis. In my application on the X axis I have time in seconds and I would like to display the steps in HH:MM:SS instead. As an alternative I am thinking of changing the display only from seconds to minutes to hours depending on the X lenght and updating the label from Time [s] to [min] to [hour]. But I would avoid that if its possible to do it the way I described. I Would appreciate all help!

When using:

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

My timeline starts from hour 1 instead of 0: enter image description here Is there a way to fix this?

like image 716
Łukasz Przeniosło Avatar asked Sep 13 '25 09:09

Łukasz Przeniosło


1 Answers

You can use setTickLabelType() and setDateTimeFormat:

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

The format string is built according to the the format string of QDateTime::toString().

like image 193
m.s. Avatar answered Sep 14 '25 23:09

m.s.