I'm beginner at Qt, and currently learning from Mastering Qt5 book and I got stuck. There is a piece of code
// Global variables
const int CHART_X_RANGE_COUNT = 50;
const int CHART_X_RANGE_MAX = CHART_X_RANGE_COUNT - 1;
void MemoryWidget::updateSeries()
{
double memoryUsed = SysInfo::instance().memoryUsed(); // retrieve the latest memory percentage used
mSeries->append(mPointPositionX++, memoryUsed);
if (mSeries->count() > CHART_X_RANGE_COUNT)
{
QChart *chart = chartView().chart();
chart->scroll(chart->plotArea().width() / CHART_X_RANGE_MAX, 0);
mSeries->remove(0);
}
}
I only don't understand the following piece of code
chart->scroll(chart->plotArea().width() / CHART_X_RANGE_MAX, 0);
If I want to scroll to the latest point on the X axis and nothing on Y, then why i have to do this:
chart->plotArea().width() / CHART_X_RANGE_MAX
and can't do just this:
chart->scroll(1, 0);