diff options
| author | Ece Cinucen <ece.cinucen@qt.io> | 2025-04-24 18:22:55 +0200 |
|---|---|---|
| committer | Ece Cinucen <ece.cinucen@qt.io> | 2025-05-12 09:29:17 +0000 |
| commit | 7888102b5bd56df7f8d0ec1bf6dd4e19a32a81f0 (patch) | |
| tree | c2545d7e7ace0042a46c9a26c0df41bb5fd536a8 /examples/graphs/2d/graphsaudio/GraphsAudio/Main.qml | |
| parent | 9ad97270b5ce1b0ef8103041e7309744825f1810 (diff) | |
Example: Port qtcharts audio example to qtgraphs
Task-number: PYSIDE-841
Pick-to: 6.8 6.9
Change-Id: Id8a81c06078c147eb50f1f1d688841e8a6bab18b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples/graphs/2d/graphsaudio/GraphsAudio/Main.qml')
| -rw-r--r-- | examples/graphs/2d/graphsaudio/GraphsAudio/Main.qml | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/graphs/2d/graphsaudio/GraphsAudio/Main.qml b/examples/graphs/2d/graphsaudio/GraphsAudio/Main.qml new file mode 100644 index 000000000..51bf3ef12 --- /dev/null +++ b/examples/graphs/2d/graphsaudio/GraphsAudio/Main.qml @@ -0,0 +1,50 @@ +// Copyright (C) 2025 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import QtQuick.Controls +import QtGraphs + +ApplicationWindow { + visible: true + width: 1000 + height: 800 + title: "Data from the microphone (" + device_name + ")" + + GraphsView { + id: graph + anchors.fill: parent + + LineSeries { + id: audio_series + width: 2 + color: "#007acc" + } + + axisX: ValueAxis { + min: 0 + max: 2000 + tickInterval : 500 + labelFormat: "%g" + titleText: "Samples" + } + + axisY: ValueAxis { + min: -1 + max: 1 + tickInterval : 0.5 + labelFormat: "%0.1f" + titleText: "Audio level" + } + } + + Connections { + target: audio_bridge + function onDataUpdated(buffer) { + audio_series.clear() + for (let i = 0; i < buffer.length; ++i) { + audio_series.append(buffer[i]) + } + } + } +} |
