##// END OF EJS Templates
Added minimalistic scatter example
Tero Ahola -
r123:587658ab0a6d
parent child
Show More
@@ -0,0 +1,37
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
3 #include <cmath>
4 #include <qchartglobal.h>
5 #include <qchartwidget.h>
6 #include <qscatterseries.h>
7
8 QTCOMMERCIALCHART_USE_NAMESPACE
9
10 int main(int argc, char *argv[])
11 {
12 QApplication a(argc, argv);
13
14 // Create widget and scatter series
15 QChartWidget chartWidget;
16 QScatterSeries *scatter =
17 qobject_cast<QScatterSeries *>(chartWidget.createSeries(QChartSeries::SeriesTypeScatter));
18 Q_ASSERT(scatter);
19
20 // Add test data to the series
21 QList<qreal> x;
22 QList<qreal> y;
23 for (qreal i(0.0); i < 20; i += 0.5) {
24 // Linear data with random component
25 x.append(i + ((qreal)(rand() % 100)) / 100 );
26 y.append(i + ((qreal)(rand() % 100)) / 100 );
27 }
28 scatter->setData(x, y);
29
30 // Use the chart widget as the central widget
31 QMainWindow w;
32 w.resize(640, 480);
33 w.setCentralWidget(&chartWidget);
34 w.show();
35
36 return a.exec();
37 }
@@ -0,0 +1,17
1 !include( ../../common.pri ) {
2 error( "Couldn't find the common.pri file!" )
3 }
4 !include( ../../integrated.pri ) {
5 error( "Couldn't find the integrated.pri file !")
6 }
7
8 QT += core gui
9
10 TARGET = scatter
11 TEMPLATE = app
12
13 SOURCES += main.cpp
14
15 HEADERS +=
16
17
@@ -4,4 +4,6 SUBDIRS += linechart \
4 colorlinechart \
4 colorlinechart \
5 barchart \
5 barchart \
6 stackedbarchart \
6 stackedbarchart \
7 percentbarchart
7 percentbarchart \
8 scatter
9
General Comments 0
You need to be logged in to leave comments. Login now