diff options
Diffstat (limited to 'examples/datavisualization/qmllegend')
-rw-r--r-- | examples/datavisualization/qmllegend/CMakeLists.txt | 54 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/doc/images/qmllegend-example.png | bin | 98023 -> 0 bytes | |||
-rw-r--r-- | examples/datavisualization/qmllegend/doc/src/qmllegend.qdoc | 54 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/main.cpp | 34 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/qml/qmllegend/Data.qml | 63 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/qml/qmllegend/LegendItem.qml | 109 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/qml/qmllegend/main.qml | 215 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/qmllegend.pro | 13 | ||||
-rw-r--r-- | examples/datavisualization/qmllegend/qmllegend.qrc | 7 |
9 files changed, 0 insertions, 549 deletions
diff --git a/examples/datavisualization/qmllegend/CMakeLists.txt b/examples/datavisualization/qmllegend/CMakeLists.txt deleted file mode 100644 index ed972f4b..00000000 --- a/examples/datavisualization/qmllegend/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -project(qmllegend LANGUAGES CXX) - -set(CMAKE_INCLUDE_CURRENT_DIR ON) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTORCC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}") - -find_package(Qt6 COMPONENTS Core) -find_package(Qt6 COMPONENTS Gui) -find_package(Qt6 COMPONENTS Qml) -find_package(Qt6 COMPONENTS Quick) -find_package(Qt6 COMPONENTS DataVisualization) - -qt_add_executable(qmllegend - main.cpp -) -set_target_properties(qmllegend PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) -target_link_libraries(qmllegend PUBLIC - Qt::Core - Qt::Gui - Qt::Qml - Qt::Quick - Qt::DataVisualization -) - -set(qmllegend_resource_files - "qml/qmllegend/Data.qml" - "qml/qmllegend/LegendItem.qml" - "qml/qmllegend/main.qml" -) - -qt6_add_resources(qmllegend "qmllegend" - PREFIX - "/" - FILES - ${qmllegend_resource_files} -) - -install(TARGETS qmllegend - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/datavisualization/qmllegend/doc/images/qmllegend-example.png b/examples/datavisualization/qmllegend/doc/images/qmllegend-example.png Binary files differdeleted file mode 100644 index ee546077..00000000 --- a/examples/datavisualization/qmllegend/doc/images/qmllegend-example.png +++ /dev/null diff --git a/examples/datavisualization/qmllegend/doc/src/qmllegend.qdoc b/examples/datavisualization/qmllegend/doc/src/qmllegend.qdoc deleted file mode 100644 index a2b78161..00000000 --- a/examples/datavisualization/qmllegend/doc/src/qmllegend.qdoc +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example qmllegend - \title Qt Quick 2 Legend Example - \ingroup qtdatavisualization_examples - \brief Showing graph legend in a QML application. - - The Qt Quick 2 legend example shows how to make an interactive legend for a graph. - - \image qmllegend-example.png - - The interesting thing about this example is displaying the legend. We'll concentrate on - that and skip explaining the basic functionality - for - more detailed QML example documentation, see \l{Qt Quick 2 Scatter Example}. - - \include examples-run.qdocinc - - \section1 Legend - - The legend is simply a column of custom \c LegendItem items inside a transparent rectangle. - Each item is supplied with a series and the graph theme: - - \snippet qmllegend/qml/qmllegend/main.qml 0 - - The legend items consist of a marker rectangle, which indicates the color of the series, - and a text field, which shows the name of the series. The colors we get from the series and - the theme supplied at legend item initialization: - - \snippet qmllegend/qml/qmllegend/LegendItem.qml 0 - \dots 4 - \snippet qmllegend/qml/qmllegend/LegendItem.qml 1 - - We want the legend to be interactive, so we add additional logic to enable selection of a - series by clicking on a legend item, as well as highlighting the legend item corresponding - to the selected series. - - The highlight depends on the selection state of the series, so we define two states, which - follow the Bar3DSeries::selectedBar property and adjust the \c legendItem color appropriately: - - \snippet qmllegend/qml/qmllegend/LegendItem.qml 3 - - To make the legend item interactive, we define a MouseArea to detect clicks on it and adjust - the series selection accordingly: - - \snippet qmllegend/qml/qmllegend/LegendItem.qml 2 - - The \c previousSelection used above is another custom property of \c LegendItem, which we update - whenever selection changes on the series. This way we remember the last selected bar of - each series: - - \snippet qmllegend/qml/qmllegend/LegendItem.qml 4 -*/ diff --git a/examples/datavisualization/qmllegend/main.cpp b/examples/datavisualization/qmllegend/main.cpp deleted file mode 100644 index 81885deb..00000000 --- a/examples/datavisualization/qmllegend/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -#include <QtGui/QGuiApplication> -#include <QtCore/QDir> -#include <QtQuick/QQuickView> -#include <QtQml/QQmlEngine> - -int main(int argc, char *argv[]) -{ - qputenv("QSG_RHI_BACKEND", "opengl"); - QGuiApplication app(argc, argv); - - QQuickView viewer; - - // The following are needed to make examples run without having to install the module - // in desktop environments. -#ifdef Q_OS_WIN - QString extraImportPath(QStringLiteral("%1/../../../../%2")); -#else - QString extraImportPath(QStringLiteral("%1/../../../%2")); -#endif - viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), - QString::fromLatin1("qml"))); - QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); - - viewer.setTitle(QStringLiteral("Legend example")); - - viewer.setSource(QUrl("qrc:/qml/qmllegend/main.qml")); - viewer.setResizeMode(QQuickView::SizeRootObjectToView); - viewer.show(); - - return app.exec(); -} diff --git a/examples/datavisualization/qmllegend/qml/qmllegend/Data.qml b/examples/datavisualization/qmllegend/qml/qmllegend/Data.qml deleted file mode 100644 index 356d5c50..00000000 --- a/examples/datavisualization/qmllegend/qml/qmllegend/Data.qml +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick - -Item { - property alias model: dataModel - - ListModel { - id: dataModel - ListElement{ year: "2010"; month: "Jan"; s1: "-14"; s2: "-15"; s3: "-15" } - ListElement{ year: "2010"; month: "Feb"; s1: "-15"; s2: "-16"; s3: "-9" } - ListElement{ year: "2010"; month: "Mar"; s1: "-7"; s2: "-4"; s3: "-2" } - ListElement{ year: "2010"; month: "Apr"; s1: "3"; s2: "2"; s3: "2" } - ListElement{ year: "2010"; month: "May"; s1: "7"; s2: "9"; s3: "10" } - ListElement{ year: "2010"; month: "Jun"; s1: "12"; s2: "13"; s3: "22" } - ListElement{ year: "2010"; month: "Jul"; s1: "18"; s2: "19"; s3: "24" } - ListElement{ year: "2010"; month: "Aug"; s1: "15"; s2: "13"; s3: "16" } - ListElement{ year: "2010"; month: "Sep"; s1: "6"; s2: "3"; s3: "4" } - ListElement{ year: "2010"; month: "Oct"; s1: "1"; s2: "2"; s3: "-2" } - ListElement{ year: "2010"; month: "Nov"; s1: "-2"; s2: "-5"; s3: "-6" } - ListElement{ year: "2010"; month: "Dec"; s1: "-3"; s2: "-3"; s3: "-9" } - - ListElement{ year: "2011"; month: "Jan"; s1: "-12"; s2: "-11"; s3: "-14" } - ListElement{ year: "2011"; month: "Feb"; s1: "-13"; s2: "-12"; s3: "-10" } - ListElement{ year: "2011"; month: "Mar"; s1: "-6"; s2: "-4"; s3: "-3" } - ListElement{ year: "2011"; month: "Apr"; s1: "0"; s2: "1"; s3: "3" } - ListElement{ year: "2011"; month: "May"; s1: "4"; s2: "12"; s3: "11" } - ListElement{ year: "2011"; month: "Jun"; s1: "9"; s2: "17"; s3: "23" } - ListElement{ year: "2011"; month: "Jul"; s1: "15"; s2: "22"; s3: "25" } - ListElement{ year: "2011"; month: "Aug"; s1: "12"; s2: "15"; s3: "12" } - ListElement{ year: "2011"; month: "Sep"; s1: "2"; s2: "4"; s3: "7" } - ListElement{ year: "2011"; month: "Oct"; s1: "-2"; s2: "4"; s3: "-4" } - ListElement{ year: "2011"; month: "Nov"; s1: "-4"; s2: "-8"; s3: "-5" } - ListElement{ year: "2011"; month: "Dec"; s1: "-6"; s2: "-6"; s3: "-7" } - - ListElement{ year: "2012"; month: "Jan"; s1: "-10"; s2: "-19"; s3: "-11" } - ListElement{ year: "2012"; month: "Feb"; s1: "-11"; s2: "-17"; s3: "-4" } - ListElement{ year: "2012"; month: "Mar"; s1: "-6"; s2: "-3"; s3: "-1" } - ListElement{ year: "2012"; month: "Apr"; s1: "5"; s2: "1"; s3: "2" } - ListElement{ year: "2012"; month: "May"; s1: "9"; s2: "12"; s3: "13" } - ListElement{ year: "2012"; month: "Jun"; s1: "11"; s2: "16"; s3: "26" } - ListElement{ year: "2012"; month: "Jul"; s1: "18"; s2: "20"; s3: "23" } - ListElement{ year: "2012"; month: "Aug"; s1: "19"; s2: "12"; s3: "12" } - ListElement{ year: "2012"; month: "Sep"; s1: "9"; s2: "1"; s3: "3" } - ListElement{ year: "2012"; month: "Oct"; s1: "-3"; s2: "2"; s3: "-1" } - ListElement{ year: "2012"; month: "Nov"; s1: "-5"; s2: "-4"; s3: "-3" } - ListElement{ year: "2012"; month: "Dec"; s1: "-7"; s2: "-2"; s3: "-4" } - - ListElement{ year: "2013"; month: "Jan"; s1: "-18"; s2: "-19"; s3: "-19" } - ListElement{ year: "2013"; month: "Feb"; s1: "-17"; s2: "-19"; s3: "-12" } - ListElement{ year: "2013"; month: "Mar"; s1: "-9"; s2: "-6"; s3: "-5" } - ListElement{ year: "2013"; month: "Apr"; s1: "0"; s2: "0"; s3: "0" } - ListElement{ year: "2013"; month: "May"; s1: "4"; s2: "7"; s3: "9" } - ListElement{ year: "2013"; month: "Jun"; s1: "9"; s2: "11"; s3: "18" } - ListElement{ year: "2013"; month: "Jul"; s1: "13"; s2: "15"; s3: "20" } - ListElement{ year: "2013"; month: "Aug"; s1: "10"; s2: "11"; s3: "13" } - ListElement{ year: "2013"; month: "Sep"; s1: "3"; s2: "1"; s3: "2" } - ListElement{ year: "2013"; month: "Oct"; s1: "0"; s2: "1"; s3: "-4" } - ListElement{ year: "2013"; month: "Nov"; s1: "-5"; s2: "-6"; s3: "-5" } - ListElement{ year: "2013"; month: "Dec"; s1: "-6"; s2: "-7"; s3: "-10" } - } -} diff --git a/examples/datavisualization/qmllegend/qml/qmllegend/LegendItem.qml b/examples/datavisualization/qmllegend/qml/qmllegend/LegendItem.qml deleted file mode 100644 index a3a4d198..00000000 --- a/examples/datavisualization/qmllegend/qml/qmllegend/LegendItem.qml +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Layouts -import QtQuick.Window -import QtDataVisualization 1.2 - -Rectangle { - //! [0] - property Theme3D theme - property Bar3DSeries series - //! [0] - property point previousSelection - - id: legendItem - state: "unselected" - - // Workaround for a layout bug that in some situations causes changing from fully opaque color - // to a transparent one to use black background instead of what is actually under the items. - // Having the control always slighthly transparent forces the background to be refreshed - // properly. - opacity: 0.999 - - //! [1] - RowLayout { - anchors.fill: parent - spacing: 0 - clip: true - Item { - id: markerSpace - Layout.minimumWidth: 20 - Layout.minimumHeight: 20 - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignVCenter - Rectangle { - x: parent.x + parent.width / 4 - y: parent.y + parent.height / 4 - width: parent.width / 2 - height: width - border.color: "black" - color: series.baseColor - } - } - Item { - height: markerSpace.height - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignVCenter - Layout.minimumWidth: 100 - Text { - anchors.fill: parent - text: series.name - verticalAlignment: Text.AlignVCenter - clip: true - color: theme.labelTextColor - font: theme.font - } - } - } - //! [1] - - //! [2] - MouseArea { - id: mouseArea - anchors.fill: legendItem - onClicked: { - if (legendItem.state === "selected") { - series.selectedBar = series.invalidSelectionPosition - } else { - series.selectedBar = previousSelection - } - } - } - //! [2] - - //! [4] - Connections { - target: series - function onSelectedBarChanged(position) { - if (position !== series.invalidSelectionPosition) { - previousSelection = position - } - } - } - //! [4] - - //! [3] - states: [ - State { - name: "selected" - when: series.selectedBar != series.invalidSelectionPosition - PropertyChanges { - target: legendItem - color: series.singleHighlightColor - } - }, - State { - name: "unselected" - when: series.selectedBar == series.invalidSelectionPosition - PropertyChanges { - target: legendItem - color: theme.labelBackgroundColor - } - } - ] - //! [3] -} diff --git a/examples/datavisualization/qmllegend/qml/qmllegend/main.qml b/examples/datavisualization/qmllegend/qml/qmllegend/main.qml deleted file mode 100644 index 369a3e6d..00000000 --- a/examples/datavisualization/qmllegend/qml/qmllegend/main.qml +++ /dev/null @@ -1,215 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only - -import QtQuick -import QtQuick.Controls -import QtQuick.Layouts -import QtDataVisualization 1.2 -import "." - -Item { - id: mainView - width: 800 - height: 600 - - property int buttonLayoutHeight: 180; - - Data { - id: graphData - } - - Theme3D { - id: firstTheme - type: Theme3D.ThemeQt - } - - Theme3D { - id: secondTheme - type: Theme3D.ThemeEbony - } - - Item { - id: dataView - anchors.fill: parent - - Bars3D { - id: barGraph - anchors.fill: parent - selectionMode: AbstractGraph3D.SelectionItemAndRow - scene.activeCamera.cameraPreset: Camera3D.CameraPresetIsometricLeftHigh - theme: firstTheme - valueAxis.labelFormat: "%d\u00B0C" - - Bar3DSeries { - id: station1 - name: "Station 1" - itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel" - - ItemModelBarDataProxy { - itemModel: graphData.model - rowRole: "year" - columnRole: "month" - valueRole: "s1" - } - } - Bar3DSeries { - id: station2 - name: "Station 2" - itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel" - - ItemModelBarDataProxy { - itemModel: graphData.model - rowRole: "year" - columnRole: "month" - valueRole: "s2" - } - } - Bar3DSeries { - id: station3 - name: "Station 3" - itemLabelFormat: "Temperature at @seriesName for @colLabel, @rowLabel: @valueLabel" - - ItemModelBarDataProxy { - itemModel: graphData.model - rowRole: "year" - columnRole: "month" - valueRole: "s2" - } - } - } - } - - Rectangle { - property int legendLocation: 3 - // Make the height and width fractional of main view height and width. - // Reverse the relation if screen is in portrait - this makes legend look the same - // if the orientation is rotated. - property int fractionalHeight: mainView.width > mainView.height ? mainView.height / 5 : mainView.width / 5 - property int fractionalWidth: mainView.width > mainView.height ? mainView.width / 5 : mainView.height / 5 - - id: legendPanel - width: fractionalWidth > 150 ? fractionalWidth : 150 - // Adjust legendpanel height to avoid gaps between layouted items. - height: fractionalHeight > 99 ? fractionalHeight - fractionalHeight % 3 : 99 - border.color: barGraph.theme.labelTextColor - border.width: 3 - color: "#00000000" // Transparent - - //! [0] - ColumnLayout { - anchors.fill: parent - anchors.margins: parent.border.width - spacing: 0 - clip: true - LegendItem { - Layout.fillWidth: true - Layout.fillHeight: true - series: station1 - theme: barGraph.theme - } - LegendItem { - Layout.fillWidth: true - Layout.fillHeight: true - series: station2 - theme: barGraph.theme - } - LegendItem { - Layout.fillWidth: true - Layout.fillHeight: true - series: station3 - theme: barGraph.theme - } - } - //! [0] - - states: [ - State { - name: "topleft" - when: legendPanel.legendLocation === 1 - AnchorChanges { - target: legendPanel - anchors.top: buttonLayout.bottom - anchors.bottom: undefined - anchors.left: dataView.left - anchors.right: undefined - } - }, - State { - name: "topright" - when: legendPanel.legendLocation === 2 - AnchorChanges { - target: legendPanel - anchors.top: buttonLayout.bottom - anchors.bottom: undefined - anchors.left: undefined - anchors.right: dataView.right - } - }, - State { - name: "bottomleft" - when: legendPanel.legendLocation === 3 - AnchorChanges { - target: legendPanel - anchors.top: undefined - anchors.bottom: dataView.bottom - anchors.left: dataView.left - anchors.right: undefined - } - }, - State { - name: "bottomright" - when: legendPanel.legendLocation === 4 - AnchorChanges { - target: legendPanel - anchors.top: undefined - anchors.bottom: dataView.bottom - anchors.left: undefined - anchors.right: dataView.right - } - } - ] - } - - RowLayout { - id: buttonLayout - Layout.minimumHeight: themeToggle.height - width: parent.width - anchors.left: parent.left - spacing: 0 - - Button { - id: themeToggle - Layout.fillHeight: true - Layout.fillWidth: true - text: "Change Theme" - onClicked: { - if (barGraph.theme === firstTheme) { - barGraph.theme = secondTheme - } else { - barGraph.theme = firstTheme - } - } - } - Button { - id: repositionLegend - Layout.fillHeight: true - Layout.fillWidth: true - text: "Reposition Legend" - onClicked: { - if (legendPanel.legendLocation === 4) { - legendPanel.legendLocation = 1 - } else { - legendPanel.legendLocation++ - } - } - } - Button { - id: exitButton - Layout.fillHeight: true - Layout.fillWidth: true - text: "Quit" - onClicked: Qt.quit(); - } - } - -} diff --git a/examples/datavisualization/qmllegend/qmllegend.pro b/examples/datavisualization/qmllegend/qmllegend.pro deleted file mode 100644 index af449d8d..00000000 --- a/examples/datavisualization/qmllegend/qmllegend.pro +++ /dev/null @@ -1,13 +0,0 @@ -!include( ../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -# The .cpp file which was generated for your project. Feel free to hack it. -SOURCES += main.cpp - -RESOURCES += qmllegend.qrc - -OTHER_FILES += doc/src/* \ - doc/images/* \ - qml/qmllegend/* - diff --git a/examples/datavisualization/qmllegend/qmllegend.qrc b/examples/datavisualization/qmllegend/qmllegend.qrc deleted file mode 100644 index e9b0f4b9..00000000 --- a/examples/datavisualization/qmllegend/qmllegend.qrc +++ /dev/null @@ -1,7 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>qml/qmllegend/Data.qml</file> - <file>qml/qmllegend/LegendItem.qml</file> - <file>qml/qmllegend/main.qml</file> - </qresource> -</RCC> |