Hallo,

I am running a timeline-like QChart. To follow the graph as data come in I continuously call a slot to dateTimeAxis->setMin and ->setMax.

Qt Code:
  1. // create chart
  2. timeLine = new QChart();
  3.  
  4. // manage X-axis
  5. dateTimeAxis = new QDateTimeAxis;
  6. dateTimeAxis->setTickCount(9);
  7. dateTimeAxis->setFormat("hh:mm");
  8. dateTimeAxis->setMin(currentTime.addSecs(-rangeAxisX / 2));
  9. dateTimeAxis->setMax(currentTime.addSecs( rangeAxisX / 2));
  10.  
  11. chartView = new QChartView(timeLine);
  12.  
  13. connect(&timer, SIGNAL(timeout()), this, SLOT(updateChart()));
  14.  
  15. void MainWindow::updateChart(){
  16.  
  17. // get current time
  18. currentTime = QDateTime::currentDateTime();
  19.  
  20. dateTimeAxis->setMin(currentTime.addSecs(-rangeAxisX / 2));
  21. dateTimeAxis->setMax(currentTime.addSecs( rangeAxisX / 2));
  22. }
To copy to clipboard, switch view to plain text mode 

Problem: the grid does not move as one expect it to do on a timeline. Much more it remains static as the labels on the ticks change instead.

I would like to have a "moving grid" with ticks at every - lets say - five minutes.


<..|.....|.....|.....|...<
<-5---10--15---20-<


I tried a little bit around in the chartview-class and the scroll-thing. But it turned out, that (as far as my sorrier knowledge allows me to conclude) these things work in integers while my chart lives in qreal. So - this results in a quite rough user-experience.

Any idea welcome.

Thanks in advance, Lars