diff --git a/example/presenterchart/chartview.cpp b/example/presenterchart/chartview.cpp index 1953a92..d063740 100644 --- a/example/presenterchart/chartview.cpp +++ b/example/presenterchart/chartview.cpp @@ -11,15 +11,15 @@ m_index(0) QTime now = QTime::currentTime(); qsrand((uint)now.msec()); - QLineSeries* series0 = new QLineSeries(); + QLineSeries* series0 = new QLineSeries(this); QPen blue(Qt::blue); blue.setWidth(3); series0->setPen(blue); - QLineSeries* series1 = new QLineSeries(); + QLineSeries* series1 = new QLineSeries(this); QPen red(Qt::red); red.setWidth(3); series1->setPen(red); - QLineSeries* series2 = new QLineSeries(); + QLineSeries* series2 = new QLineSeries(this); QPen green(Qt::green); green.setWidth(3); series2->setPen(green); diff --git a/src/chartdataset.cpp b/src/chartdataset.cpp index b7a44c9..0155cf7 100644 --- a/src/chartdataset.cpp +++ b/src/chartdataset.cpp @@ -91,6 +91,12 @@ void ChartDataSet::removeSeries(QSeries* series) if(i==-1){ Domain* domain = m_axisDomainMap.take(axis); emit axisRemoved(axis); + if(axis!=axisY()){ + if(axis->parent()==this){ + delete axis; + axis=0; + } + } delete domain; } @@ -275,7 +281,12 @@ Domain* ChartDataSet::domain(QSeries* series) const Domain* ChartDataSet::domain(QChartAxis* axis) const { - return m_axisDomainMap.value(axis); + if(axis==axisX()) { + return m_axisDomainMap.value(axisY()); + } + else { + return m_axisDomainMap.value(axis); + } } QChartAxis* ChartDataSet::axis(QSeries* series) const