From 85338d4b701bad27f45138c6d259c4bf54b18742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Soutad=C3=A9?= Date: Sun, 29 Oct 2017 18:21:54 +0100 Subject: [PATCH] Avoid graphic flickering when changing parameters in StatsPanel --- src/view/StatsPanel.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/view/StatsPanel.cpp b/src/view/StatsPanel.cpp index 62c1200..2349174 100644 --- a/src/view/StatsPanel.cpp +++ b/src/view/StatsPanel.cpp @@ -176,12 +176,10 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT if (_chartView) { - _vbox2->removeWidget(_chartView); - delete _chartView; + _plot->removeAllSeries(); } - - _plot = new QChart(); - _plot->createDefaultAxes(); + else + _plot = new QChart(); if (monthFrom == monthTo && yearFrom == yearTo) { @@ -301,9 +299,13 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT _plot->createDefaultAxes(); _plot->setAxisX(axisX, series0); - _chartView = new QChartView(_plot); - _chartView->setRenderHint(QPainter::Antialiasing); - _vbox2->addWidget(_chartView); + + if (!_chartView) + { + _chartView = new QChartView(_plot); + _chartView->setRenderHint(QPainter::Antialiasing); + _vbox2->addWidget(_chartView); + } total = 0.0; for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++)