##// END OF EJS Templates
Fixed a double delete chrash with scatter example
Jani Honkonen -
r129:716ea76b6c6c
parent child
Show More
@@ -1,37 +1,37
1 1 #include <QtGui/QApplication>
2 2 #include <QMainWindow>
3 3 #include <cmath>
4 4 #include <qchartglobal.h>
5 5 #include <qchartwidget.h>
6 6 #include <qscatterseries.h>
7 7
8 8 QTCOMMERCIALCHART_USE_NAMESPACE
9 9
10 10 int main(int argc, char *argv[])
11 11 {
12 12 QApplication a(argc, argv);
13 13
14 14 // Create widget and scatter series
15 QChartWidget chartWidget;
15 QChartWidget *chartWidget = new QChartWidget();
16 16 QScatterSeries *scatter =
17 qobject_cast<QScatterSeries *>(chartWidget.createSeries(QChartSeries::SeriesTypeScatter));
17 qobject_cast<QScatterSeries *>(chartWidget->createSeries(QChartSeries::SeriesTypeScatter));
18 18 Q_ASSERT(scatter);
19 19
20 20 // Add test data to the series
21 21 QList<qreal> x;
22 22 QList<qreal> y;
23 23 for (qreal i(0.0); i < 20; i += 0.5) {
24 24 // Linear data with random component
25 25 x.append(i + ((qreal)(rand() % 100)) / 100 );
26 26 y.append(i + ((qreal)(rand() % 100)) / 100 );
27 27 }
28 28 scatter->setData(x, y);
29 29
30 30 // Use the chart widget as the central widget
31 31 QMainWindow w;
32 32 w.resize(640, 480);
33 w.setCentralWidget(&chartWidget);
33 w.setCentralWidget(chartWidget);
34 34 w.show();
35 35
36 36 return a.exec();
37 37 }
General Comments 0
You need to be logged in to leave comments. Login now