Avoid graphic flickering when changing parameters in StatsPanel

This commit is contained in:
Grégory Soutadé 2017-10-29 18:21:54 +01:00 committed by Grégory Soutadé
parent ada23a4092
commit 85338d4b70

View File

@ -176,12 +176,10 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
if (_chartView) if (_chartView)
{ {
_vbox2->removeWidget(_chartView); _plot->removeAllSeries();
delete _chartView;
} }
else
_plot = new QChart(); _plot = new QChart();
_plot->createDefaultAxes();
if (monthFrom == monthTo && yearFrom == yearTo) if (monthFrom == monthTo && yearFrom == yearTo)
{ {
@ -301,9 +299,13 @@ void StatsPanel::UpdateStats(int monthFrom, int yearFrom, int monthTo, int yearT
_plot->createDefaultAxes(); _plot->createDefaultAxes();
_plot->setAxisX(axisX, series0); _plot->setAxisX(axisX, series0);
_chartView = new QChartView(_plot);
_chartView->setRenderHint(QPainter::Antialiasing); if (!_chartView)
_vbox2->addWidget(_chartView); {
_chartView = new QChartView(_plot);
_chartView->setRenderHint(QPainter::Antialiasing);
_vbox2->addWidget(_chartView);
}
total = 0.0; total = 0.0;
for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++) for(i=0, categoriesIt = categories.begin(); categoriesIt != categories.end(); categoriesIt++, i++)