##// END OF EJS Templates
Fix piechartdrilldown bug. Chart was deleting the series from us.
Jani Honkonen -
r617:fd7ce4629ee8
parent child
Show More
@@ -47,6 +47,8 public:
47
47
48 void changeSeries(QSeries* series)
48 void changeSeries(QSeries* series)
49 {
49 {
50 // NOTE: if the series is owned by the chart it will be deleted
51 // here the "window" owns the series...
50 if (m_currentSeries)
52 if (m_currentSeries)
51 removeSeries(m_currentSeries);
53 removeSeries(m_currentSeries);
52 m_currentSeries = series;
54 m_currentSeries = series;
@@ -77,7 +79,7 int main(int argc, char *argv[])
77 drilldownChart->setRenderHint(QPainter::Antialiasing);
79 drilldownChart->setRenderHint(QPainter::Antialiasing);
78 drilldownChart->setChartTheme(QChart::ChartThemeVanilla);
80 drilldownChart->setChartTheme(QChart::ChartThemeVanilla);
79
81
80 QPieSeries* yearSeries = new QPieSeries(drilldownChart);
82 QPieSeries* yearSeries = new QPieSeries(&window);
81 yearSeries->setTitle("Sales by year - All");
83 yearSeries->setTitle("Sales by year - All");
82
84
83 QList<QString> months;
85 QList<QString> months;
@@ -86,7 +88,7 int main(int argc, char *argv[])
86 names << "Jane" << "John" << "Axel" << "Mary" << "Samantha" << "Bob";
88 names << "Jane" << "John" << "Axel" << "Mary" << "Samantha" << "Bob";
87
89
88 foreach (QString name, names) {
90 foreach (QString name, names) {
89 QPieSeries* series = new QPieSeries(drilldownChart);
91 QPieSeries* series = new QPieSeries(&window);
90 series->setTitle("Sales by month - " + name);
92 series->setTitle("Sales by month - " + name);
91
93
92 foreach (QString month, months)
94 foreach (QString month, months)
@@ -102,7 +104,7 int main(int argc, char *argv[])
102 drilldownChart->changeSeries(yearSeries);
104 drilldownChart->changeSeries(yearSeries);
103
105
104 window.setCentralWidget(drilldownChart);
106 window.setCentralWidget(drilldownChart);
105 window.resize(600, 600);
107 window.resize(800, 600);
106 window.show();
108 window.show();
107
109
108 return a.exec();
110 return a.exec();
General Comments 0
You need to be logged in to leave comments. Login now