@@ -0,0 +1,18 | |||
|
1 | #include <QtGui/QApplication> | |
|
2 | #include <QMainWindow> | |
|
3 | #include "multichartwidget.h" | |
|
4 | ||
|
5 | int main(int argc, char *argv[]) | |
|
6 | { | |
|
7 | QApplication a(argc, argv); | |
|
8 | ||
|
9 | MultiChartWidget *multi = new MultiChartWidget(); | |
|
10 | ||
|
11 | // Use the chart widget as the central widget | |
|
12 | QMainWindow w; | |
|
13 | w.resize(640, 480); | |
|
14 | w.setCentralWidget(multi); | |
|
15 | w.show(); | |
|
16 | ||
|
17 | return a.exec(); | |
|
18 | } |
@@ -0,0 +1,21 | |||
|
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 = multichart | |
|
11 | TEMPLATE = app | |
|
12 | ||
|
13 | SOURCES += main.cpp \ | |
|
14 | multichartwidget.cpp | |
|
15 | ||
|
16 | HEADERS += \ | |
|
17 | multichartwidget.h | |
|
18 | ||
|
19 | ||
|
20 | ||
|
21 |
@@ -0,0 +1,35 | |||
|
1 | #include "multichartwidget.h" | |
|
2 | #include <QVBoxLayout> | |
|
3 | #include <qchartglobal.h> | |
|
4 | #include <qchartview.h> | |
|
5 | #include <qscatterseries.h> | |
|
6 | #include <qpieseries.h> | |
|
7 | ||
|
8 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
9 | ||
|
10 | MultiChartWidget::MultiChartWidget(QWidget *parent) : | |
|
11 | QWidget(parent) | |
|
12 | { | |
|
13 | QVBoxLayout *l = new QVBoxLayout(this); | |
|
14 | ||
|
15 | // Create chart 1 and add a simple pie series onto it | |
|
16 | QChartView *chartView1 = new QChartView(); | |
|
17 | l->addWidget(chartView1); | |
|
18 | QPieSeries *pie = new QPieSeries(); | |
|
19 | pie->add(QPieSlice(1.1, "label1")); | |
|
20 | pie->add(QPieSlice(1.2, "label2")); | |
|
21 | chartView1->addSeries(pie); | |
|
22 | ||
|
23 | // Create chart 2 and add a simple scatter series onto it | |
|
24 | QChartView *chartView2 = new QChartView(); | |
|
25 | l->addWidget(chartView2); | |
|
26 | QScatterSeries *scatter = new QScatterSeries(); | |
|
27 | *scatter << QPointF(0.5, 5.0) | |
|
28 | << QPointF(1.0, 4.5) | |
|
29 | << QPointF(1.0, 5.5) | |
|
30 | << QPointF(1.5, 5.0) | |
|
31 | << QPointF(2.0, 4.5) | |
|
32 | << QPointF(2.0, 5.5) | |
|
33 | << QPointF(2.5, 5.0); | |
|
34 | chartView2->addSeries(scatter); | |
|
35 | } |
General Comments 0
You need to be logged in to leave comments.
Login now