##// END OF EJS Templates
Tuning scatter examples and screens
Tero Ahola -
r398:406174ca742b
parent child
Show More
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,51 +1,50
1 #include <QtGui/QApplication>
1 #include <QtGui/QApplication>
2 #include <QMainWindow>
2 #include <QMainWindow>
3 #include <qchartglobal.h>
3 #include <qchartglobal.h>
4 #include <qchartview.h>
4 #include <qchartview.h>
5 #include <qscatterseries.h>
5 #include <qscatterseries.h>
6
6
7 QTCOMMERCIALCHART_USE_NAMESPACE
7 QTCOMMERCIALCHART_USE_NAMESPACE
8
8
9 int main(int argc, char *argv[])
9 int main(int argc, char *argv[])
10 {
10 {
11 QApplication a(argc, argv);
11 QApplication a(argc, argv);
12
12
13 //! [1]
13 //! [1]
14 // Create chart view
14 // Create chart view
15 QChartView *chartView = new QChartView();
15 QChartView *chartView = new QChartView();
16 chartView->setRenderHint(QPainter::Antialiasing);
16 chartView->setRenderHint(QPainter::Antialiasing);
17 chartView->setChartTheme(QChart::ChartThemeScientific);
18 // Add scatter series with linear test data with random "noise"
17 // Add scatter series with linear test data with random "noise"
19 QScatterSeries *scatter = new QScatterSeries();
18 QScatterSeries *scatter = new QScatterSeries();
20 for (qreal i(0.0); i < 20; i += 0.25) {
19 for (qreal i(0.0); i < 20; i += 0.5) {
21 qreal x = i + (qreal)(rand() % 100) / 100.0;
20 qreal x = i + (qreal)(rand() % 100) / 100.0;
22 qreal y = i + (qreal)(rand() % 100) / 100.0;
21 qreal y = i + (qreal)(rand() % 100) / 100.0;
23 (*scatter) << QPointF(x, y);
22 (*scatter) << QPointF(x, y);
24 }
23 }
25 // Chart takes ownership
24 // Chart takes ownership
26 chartView->addSeries(scatter);
25 chartView->addSeries(scatter);
27 //! [1]
26 //! [1]
28
27
29 // And more
28 // And more
30 //! [2]
29 //! [2]
31 //*scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
30 *scatter << QPointF(2.0, 5.5) << QPointF(2.2, 5.4);
32 //! [2]
31 //! [2]
33
32
34 //! [3]
33 //! [3]
35 QBrush brush(QColor(255, 0, 0, 80), Qt::SolidPattern);
34 QBrush brush(QColor(255, 0, 0, 80), Qt::SolidPattern);
36 scatter->setBrush(brush);
35 scatter->setBrush(brush);
37 QPen pen(QColor(0, 255, 0, 60), 3);
36 QPen pen(QColor(0, 255, 0, 60), 3);
38 scatter->setPen(pen);
37 scatter->setPen(pen);
39 scatter->setShape(QScatterSeries::MarkerShapeRectangle);
38 scatter->setShape(QScatterSeries::MarkerShapeRectangle);
40 scatter->setSize(15.0);
39 scatter->setSize(25.0);
41 //! [3]
40 //! [3]
42
41
43 // Use the chart widget as the central widget
42 // Use the chart widget as the central widget
44 QMainWindow w;
43 QMainWindow w;
45 w.resize(400, 300);
44 w.resize(400, 300);
46 w.setCentralWidget(chartView);
45 w.setCentralWidget(chartView);
47 w.setWindowFlags(Qt::FramelessWindowHint);
46 w.setWindowFlags(Qt::FramelessWindowHint);
48 w.show();
47 w.show();
49
48
50 return a.exec();
49 return a.exec();
51 }
50 }
General Comments 0
You need to be logged in to leave comments. Login now