@@ -0,0 +1,10 | |||
|
1 | !include( ../common.pri ) { | |
|
2 | error( "Couldn't find the common.pri file!" ) | |
|
3 | } | |
|
4 | ||
|
5 | !include( ../integrated.pri ) { | |
|
6 | error( "Couldn't find the integrated.pri file !") | |
|
7 | } | |
|
8 | ||
|
9 | TEMPLATE = app | |
|
10 | QT += core gui No newline at end of file |
@@ -0,0 +1,57 | |||
|
1 | #include "chartview.h" | |
|
2 | #include <qlinechartseries.h> | |
|
3 | #include <QTime> | |
|
4 | ||
|
5 | ChartView::ChartView(QWidget* parent):QChartView(parent), | |
|
6 | m_index(0) | |
|
7 | { | |
|
8 | QObject::connect(&m_timer,SIGNAL(timeout()),this,SLOT(handleTimeout())); | |
|
9 | m_timer.setInterval(3000); | |
|
10 | ||
|
11 | QTime now = QTime::currentTime(); | |
|
12 | qsrand((uint)now.msec()); | |
|
13 | ||
|
14 | QLineChartSeries* series0 = new QLineChartSeries(); | |
|
15 | QPen blue(Qt::blue); | |
|
16 | blue.setWidth(3); | |
|
17 | series0->setPen(blue); | |
|
18 | QLineChartSeries* series1 = new QLineChartSeries(); | |
|
19 | QPen red(Qt::red); | |
|
20 | red.setWidth(3); | |
|
21 | series1->setPen(red); | |
|
22 | QLineChartSeries* series2 = new QLineChartSeries(); | |
|
23 | QPen green(Qt::green); | |
|
24 | green.setWidth(3); | |
|
25 | series2->setPen(green); | |
|
26 | ||
|
27 | int numPoints = 10; | |
|
28 | ||
|
29 | for (int x = 0; x <= numPoints; ++x) { | |
|
30 | series0->add(x, qrand() % 100); | |
|
31 | series1->add(x, qrand() % 100); | |
|
32 | series2->add(x, qrand() % 100); | |
|
33 | } | |
|
34 | ||
|
35 | addSeries(series0); | |
|
36 | ||
|
37 | m_series<<series0; | |
|
38 | m_series<<series1; | |
|
39 | m_series<<series2; | |
|
40 | ||
|
41 | m_timer.start(); | |
|
42 | } | |
|
43 | ||
|
44 | ChartView::~ChartView() | |
|
45 | { | |
|
46 | ||
|
47 | } | |
|
48 | ||
|
49 | void ChartView::handleTimeout() | |
|
50 | { | |
|
51 | if(m_series.size()==0) return; | |
|
52 | ||
|
53 | removeSeries(m_series.at(m_index)); | |
|
54 | m_index++; | |
|
55 | m_index=m_index%m_series.size(); | |
|
56 | addSeries(m_series.at(m_index)); | |
|
57 | } |
@@ -0,0 +1,25 | |||
|
1 | #ifndef CHARTVIEW_H_ | |
|
2 | #define CHARTVIEW_H_ | |
|
3 | ||
|
4 | #include <qchartview.h> | |
|
5 | #include <QTimer> | |
|
6 | ||
|
7 | QTCOMMERCIALCHART_USE_NAMESPACE | |
|
8 | ||
|
9 | class ChartView: public QChartView | |
|
10 | { | |
|
11 | Q_OBJECT | |
|
12 | public: | |
|
13 | ChartView(QWidget* parent=0); | |
|
14 | virtual ~ChartView(); | |
|
15 | ||
|
16 | public slots: | |
|
17 | void handleTimeout(); | |
|
18 | ||
|
19 | private: | |
|
20 | QTimer m_timer; | |
|
21 | QList<QChartSeries*> m_series; | |
|
22 | int m_index; | |
|
23 | }; | |
|
24 | ||
|
25 | #endif /* CHARTVIEW_H_ */ |
@@ -0,0 +1,16 | |||
|
1 | #include "chartview.h" | |
|
2 | #include <QApplication> | |
|
3 | #include <QMainWindow> | |
|
4 | ||
|
5 | int main(int argc, char *argv[]) | |
|
6 | { | |
|
7 | QApplication a(argc, argv); | |
|
8 | QMainWindow window; | |
|
9 | ChartView chartView(&window); | |
|
10 | chartView.setRenderHint(QPainter::Antialiasing); | |
|
11 | chartView.setChartTitle("Three random line charts"); | |
|
12 | window.setCentralWidget(&chartView); | |
|
13 | window.resize(400, 300); | |
|
14 | window.show(); | |
|
15 | return a.exec(); | |
|
16 | } |
@@ -0,0 +1,6 | |||
|
1 | !include( ../example.pri ) { | |
|
2 | error( "Couldn't find the example.pri file!" ) | |
|
3 | } | |
|
4 | TARGET = presenterChart | |
|
5 | HEADERS += chartview.h | |
|
6 | SOURCES += main.cpp chartview.cpp No newline at end of file |
@@ -1,15 +1,8 | |||
|
1 |
!include( ../ |
|
|
2 |
error( "Couldn't find the |
|
|
1 | !include( ../example.pri ) { | |
|
2 | error( "Couldn't find the example.pri file!" ) | |
|
3 | 3 | } |
|
4 | ||
|
5 | !include( ../../integrated.pri ) { | |
|
6 | error( "Couldn't find the integrated.pri file !") | |
|
7 | } | |
|
8 | ||
|
9 | 4 | TARGET = axisChart |
|
10 | TEMPLATE = app | |
|
11 | QT += core gui | |
|
12 | SOURCES += main.cpp | |
|
5 | SOURCES = main.cpp | |
|
13 | 6 | |
|
14 | 7 | |
|
15 | 8 |
General Comments 0
You need to be logged in to leave comments.
Login now