main.cpp
71 lines
| 2.3 KiB
| text/x-c
|
CppLexer
|
r2854 | /**************************************************************************** | ||
|
r830 | ** | ||
|
r2854 | ** Copyright (C) 2016 The Qt Company Ltd. | ||
** Contact: https://www.qt.io/licensing/ | ||||
|
r830 | ** | ||
|
r2854 | ** This file is part of the Qt Charts module of the Qt Toolkit. | ||
|
r830 | ** | ||
|
r2854 | ** $QT_BEGIN_LICENSE:GPL$ | ||
|
r2845 | ** Commercial License Usage | ||
** Licensees holding valid commercial Qt licenses may use this file in | ||||
** accordance with the commercial license agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and The Qt Company. For licensing terms | ||||
|
r2854 | ** and conditions see https://www.qt.io/terms-conditions. For further | ||
** information use the contact form at https://www.qt.io/contact-us. | ||||
** | ||||
** GNU General Public License Usage | ||||
** Alternatively, this file may be used under the terms of the GNU | ||||
** General Public License version 3 or (at your option) any later version | ||||
** approved by the KDE Free Qt Foundation. The licenses are as published by | ||||
** the Free Software Foundation and appearing in the file LICENSE.GPL3 | ||||
** included in the packaging of this file. Please review the following | ||||
** information to ensure the GNU General Public License requirements will | ||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html. | ||||
|
r830 | ** | ||
|
r2845 | ** $QT_END_LICENSE$ | ||
** | ||||
|
r2854 | ****************************************************************************/ | ||
|
r747 | |||
|
r1187 | #include "chart.h" | ||
|
r747 | #include "chartview.h" | ||
|
r2714 | #include <QtWidgets/QApplication> | ||
#include <QtWidgets/QMainWindow> | ||||
#include <QtCore/QtMath> | ||||
#include <QtCharts/QLineSeries> | ||||
#include <QtCharts/QValueAxis> | ||||
|
r67 | |||
|
r2712 | QT_CHARTS_USE_NAMESPACE | ||
|
r67 | |||
int main(int argc, char *argv[]) | ||||
{ | ||||
QApplication a(argc, argv); | ||||
|
r747 | //![1] | ||
|
r2102 | QLineSeries *series = new QLineSeries(); | ||
|
r2098 | for (int i = 0; i < 500; i++) { | ||
|
r1388 | QPointF p((qreal) i, qSin(M_PI / 50 * i) * 100); | ||
p.ry() += qrand() % 20; | ||||
*series << p; | ||||
|
r966 | } | ||
|
r747 | //![1] | ||
|
r883 | |||
|
r2102 | Chart *chart = new Chart(); | ||
|
r966 | chart->addSeries(series); | ||
chart->setTitle("Zoom in/out example"); | ||||
|
r1187 | chart->setAnimationOptions(QChart::SeriesAnimations); | ||
|
r1388 | chart->legend()->hide(); | ||
|
r1589 | chart->createDefaultAxes(); | ||
|
r883 | |||
|
r2102 | ChartView *chartView = new ChartView(chart); | ||
|
r966 | chartView->setRenderHint(QPainter::Antialiasing); | ||
|
r883 | |||
|
r966 | QMainWindow window; | ||
window.setCentralWidget(chartView); | ||||
window.resize(400, 300); | ||||
|
r1187 | window.grabGesture(Qt::PanGesture); | ||
window.grabGesture(Qt::PinchGesture); | ||||
|
r966 | window.show(); | ||
|
r883 | |||
|
r67 | return a.exec(); | ||
} | ||||