summaryrefslogtreecommitdiffstats
path: root/examples/sensors/sensorsshowcase/Proximity.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sensors/sensorsshowcase/Proximity.qml')
-rw-r--r--examples/sensors/sensorsshowcase/Proximity.qml55
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/sensors/sensorsshowcase/Proximity.qml b/examples/sensors/sensorsshowcase/Proximity.qml
new file mode 100644
index 00000000..41121983
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Proximity.qml
@@ -0,0 +1,55 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Layouts
+import QtSensors
+
+Item {
+ id: root
+
+ required property int imageSize
+ required property int fontSize
+
+ property bool near: false
+
+ ProximitySensor {
+ id: proximity
+ onReadingChanged: root.near = (reading as ProximityReading).near
+ active: true
+ }
+
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Image {
+ id: image
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.preferredWidth: root.near ? root.imageSize : root.imageSize * 0.75
+ Layout.fillHeight: true
+
+ source: "images/qt_logo.png"
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Rectangle {
+ id: separator
+ Layout.topMargin: 10
+ Layout.bottomMargin: 10
+ Layout.preferredWidth: parent.width * 0.75
+ Layout.preferredHeight: 1
+ Layout.alignment: Qt.AlignHCenter
+ color: "black"
+ }
+
+ Text {
+ Layout.fillHeight: true
+ font.pixelSize: root.fontSize
+ text: "Near: " + root.near
+ }
+ }
+}