diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2023-05-19 13:58:19 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2023-06-13 14:23:13 +0300 |
commit | cf7c6bd4900e333b45964740f0a199b9d8709a3d (patch) | |
tree | fb3e56fc1d7e9f7becad52857d282f437630a6b7 /examples/charts/lineandbar | |
parent | 143a6627b30954ae05c49bd59dd5f91427651a97 (diff) |
Revamp examples
Separate gallery example was created for widget and qml examples and
most example code was moved under those two gallery examples.
Examples left outside galleries for various reasons:
- audio: Requires multimedia, which is an optional addon
- openglseries: Requires OpenGL backend
- qmloscilloscope: Complicated hybrid C++/QML example
- qmlweather: Uses optional command line parameter
- zoomlinechart: Uses gestures, which require grabbing main window
Cleaned up the code of the remaining examples to same standard as
galleries.
Examples documentation will be updated in a separate commit.
Task-number: QTBUG-94181
Task-number: QTBUG-111053
Task-number: QTBUG-113655
Change-Id: I6a98a4386364fcb2530e2667aea95760e6ff2983
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
(cherry picked from commit 8f4629814f3df83e9ea85aebefb0e0c9929be476)
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'examples/charts/lineandbar')
-rw-r--r-- | examples/charts/lineandbar/CMakeLists.txt | 36 | ||||
-rw-r--r-- | examples/charts/lineandbar/lineandbar.pro | 7 | ||||
-rw-r--r-- | examples/charts/lineandbar/main.cpp | 96 |
3 files changed, 0 insertions, 139 deletions
diff --git a/examples/charts/lineandbar/CMakeLists.txt b/examples/charts/lineandbar/CMakeLists.txt deleted file mode 100644 index 719f698d..00000000 --- a/examples/charts/lineandbar/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(lineandbar LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/charts/lineandbar") - -find_package(Qt6 REQUIRED COMPONENTS Charts Core Gui) - -qt_add_executable(lineandbar - main.cpp -) - -set_target_properties(lineandbar PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(lineandbar PUBLIC - Qt::Charts - Qt::Core - Qt::Gui -) - -install(TARGETS lineandbar - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/charts/lineandbar/lineandbar.pro b/examples/charts/lineandbar/lineandbar.pro deleted file mode 100644 index 073cca49..00000000 --- a/examples/charts/lineandbar/lineandbar.pro +++ /dev/null @@ -1,7 +0,0 @@ -QT += charts - -SOURCES += \ - main.cpp - -target.path = $$[QT_INSTALL_EXAMPLES]/charts/lineandbar -INSTALLS += target diff --git a/examples/charts/lineandbar/main.cpp b/examples/charts/lineandbar/main.cpp deleted file mode 100644 index 1e3e35c5..00000000 --- a/examples/charts/lineandbar/main.cpp +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -#include <QtWidgets/QApplication> -#include <QtWidgets/QMainWindow> -#include <QtCharts/QChartView> -#include <QtCharts/QBarSeries> -#include <QtCharts/QBarSet> -#include <QtCharts/QLineSeries> -#include <QtCharts/QLegend> -#include <QtCharts/QBarCategoryAxis> -#include <QtCharts/QValueAxis> - -QT_USE_NAMESPACE - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - -//![1] - QBarSet *set0 = new QBarSet("Jane"); - QBarSet *set1 = new QBarSet("John"); - QBarSet *set2 = new QBarSet("Axel"); - QBarSet *set3 = new QBarSet("Mary"); - QBarSet *set4 = new QBarSet("Sam"); - - *set0 << 1 << 2 << 3 << 4 << 5 << 6; - *set1 << 5 << 0 << 0 << 4 << 0 << 7; - *set2 << 3 << 5 << 8 << 13 << 8 << 5; - *set3 << 5 << 6 << 7 << 3 << 4 << 5; - *set4 << 9 << 7 << 5 << 3 << 1 << 2; -//![1] - -//![2] - QBarSeries *barseries = new QBarSeries(); - barseries->append(set0); - barseries->append(set1); - barseries->append(set2); - barseries->append(set3); - barseries->append(set4); -//![2] - -//![8] - QLineSeries *lineseries = new QLineSeries(); - lineseries->setName("trend"); - lineseries->append(QPoint(0, 4)); - lineseries->append(QPoint(1, 15)); - lineseries->append(QPoint(2, 20)); - lineseries->append(QPoint(3, 4)); - lineseries->append(QPoint(4, 12)); - lineseries->append(QPoint(5, 17)); -//![8] - -//![3] - QChart *chart = new QChart(); - chart->addSeries(barseries); - chart->addSeries(lineseries); - chart->setTitle("Line and barchart example"); -//![3] - -//![4] - QStringList categories; - categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; - QBarCategoryAxis *axisX = new QBarCategoryAxis(); - axisX->append(categories); - chart->addAxis(axisX, Qt::AlignBottom); - lineseries->attachAxis(axisX); - barseries->attachAxis(axisX); - axisX->setRange(QString("Jan"), QString("Jun")); - - QValueAxis *axisY = new QValueAxis(); - chart->addAxis(axisY, Qt::AlignLeft); - lineseries->attachAxis(axisY); - barseries->attachAxis(axisY); - axisY->setRange(0, 20); -//![4] - -//![5] - chart->legend()->setVisible(true); - chart->legend()->setAlignment(Qt::AlignBottom); -//![5] - -//![6] - QChartView *chartView = new QChartView(chart); - chartView->setRenderHint(QPainter::Antialiasing); -//![6] - -//![7] - QMainWindow window; - window.setCentralWidget(chartView); - window.resize(440, 300); - window.show(); -//![7] - - return a.exec(); -} |