2016-04-15 61 views
1

我使用Windows 7 x64,Qt 5.6,Visual Studio 2015,QCustomPlot 1.3.2。我需要從傳感器繪製溫度圖(實時)。我每500 ms收到一個溫度值(frequency = 2 Hz)。我應該對QCustomPlot實例應用什麼設置才能讓time_period = 10分鐘內收到最後一個值? 這裏是更新插槽的片段:設置實時QCustomPlot

double key = QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0; 
custom_plot_->graph(0)->addData(key, value); 
custom_plot_->graph(0)->removeDataBefore(old_items_count); 
custom_plot_->xAxis->setRange(key + some_delta, old_items_count, Qt::AlignRight); 

哪些變量old_items_count = func1(time_period, frequency)some_delta = func2(time_period, frequency)的公式? 官方演示包含以下值:old_items_count = 8,some_delta = 0.25

回答

1

如果您xAxis以秒爲單位,以具有恆定的範圍爲10分鐘(600秒),你將需要設置其範圍如下:

custom_plot_->xAxis->setRange(key + some_delta, 600, Qt::AlignRight); 

some_delta價值達您。看看QCPAxis Class Reference