diff options
author | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2023-01-30 13:10:05 +0200 |
---|---|---|
committer | Tomi Korpipaa <tomi.korpipaa@qt.io> | 2023-02-02 12:05:14 +0200 |
commit | 6ae51a12ccd15575197e5aeff4de3273a615c1a9 (patch) | |
tree | ed52a789b499c02d36d861eb87cc694fd805f23f /examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc | |
parent | b20a41dfb410ef0e99d73bc35dfffade48cf55cb (diff) |
Combine 2 examples into one
Combine qmlaxisdrag and qmlaxisformatter examples into one
Pick-to: 6.5
Fixes: QTBUG-110699
Change-Id: I5043089ad47370165543b7c09409ba08d5f4690d
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io>
Diffstat (limited to 'examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc')
-rw-r--r-- | examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc | 101 |
1 files changed, 0 insertions, 101 deletions
diff --git a/examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc b/examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc deleted file mode 100644 index 3dd1075f..00000000 --- a/examples/datavisualization/qmlaxisformatter/doc/src/qmlaxisformatter.qdoc +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example qmlaxisformatter - \meta tags {DataVisualization, Scatter3D, Custom Axis Formatter, Scatter Graph} - \meta category {Graphics} - \title Axis Formatters - \ingroup qtdatavisualization_qmlexamples - \brief Example of a hybrid C++ and QML application demonstrating different axis formatters. - \since QtDataVisualization 1.1 - - The Qt Quick axis formatters example shows how to use predefined axis formatters and how to - create a custom one. - - \image qmlaxisformatter-example.png - - The interesting thing about this example is axis formatters, so we'll concentrate on - that and skip explaining the basic functionality - for - more detailed QML example documentation, see \l{Simple Scatter Graph}. - - \include examples-run.qdocinc - - \section1 Custom Axis Formatter - - Customizing axis formatters requires subclassing the QValue3DAxisFormatter, which cannot be - done in QML code alone. In this example we want an axis that interprets the float values as - a timestamp and shows the date in the axis labels. To achieve this, we introduce a new class - called \c CustomFormatter, which subclasses the QValue3DAxisFormatter: - - \snippet qmlaxisformatter/customformatter.h 2 - \dots 0 - - Since float values of a QScatter3DSeries cannot be directly cast into QDateTime values due to - difference in data width, we need some sort of mapping between the two. We chose to do the - mapping by specifying an origin date for the formatter and interpreting the float values - from the QScatter3DSeries as date offsets to that origin value. The origin date is given as - a property: - - \snippet qmlaxisformatter/customformatter.h 1 - - The mapping from value to QDateTime is done using \c valueToDateTime() method: - - \snippet qmlaxisformatter/customformatter.cpp 0 - - To function as an axis formatter, our \c CustomFormatter needs to reimplement some virtual - methods: - - \snippet qmlaxisformatter/customformatter.h 0 - - The first two are simple, we just create a new instance of \c CustomFormatter and copy the - necessary data over to it. These two methods are used to create and update a cache of formatter for - rendering purposes. It is important to remember to call the superclass implementation - of \c populateCopy(): - - \snippet qmlaxisformatter/customformatter.cpp 1 - - Bulk of the work done by \c CustomFormatter is done in the \c recalculate() method, where - our formatter calculates the grid, subgrid, and label positions, as well as formats the label - strings. - In our custom formatter we ignore the segment count of the axis and draw a grid line always at - midnight. Subsegment count and label positioning is handled normally: - - \snippet qmlaxisformatter/customformatter.cpp 2 - - The axis labels are formatted to show only the date, but for selection label we want little more - resolution for the timestamp, so we specify another property for our custom formatter to allow - user to customize it: - - \snippet qmlaxisformatter/customformatter.h 3 - - This selection format property is used in the reimplemented \c stringToValue method, where we - ignore the submitted format and substitute the custom selection format for it: - - \snippet qmlaxisformatter/customformatter.cpp 3 - - To expose our new custom formatter to the QML, we must declare it and make it a QML module. - Doing this was introduced in the \l{Surface Oscilloscope} so we will skip it here. - - \section1 QML - - In the QML codes, we define a different axis for each dimension: - - \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 3 - - Z-axis is just a regular ValueAxis3D: - - \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 0 - - For the Y-axis we define a logarithmic axis. ValueAxis3D can be made to show logarithmic scale - by specifying LogValueAxis3DFormatter for \c formatter property of the axis: - - \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 2 - - And finally, for the X-axis we use our new \c CustomFormatter: - - \snippet qmlaxisformatter/qml/qmlaxisformatter/main.qml 1 - - Rest of the application consists of fairly self-explanatory logic for modifying the axes and - showing the graph. -*/ |