summaryrefslogtreecommitdiffstats
path: root/src/sensors/doc/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'src/sensors/doc/snippets')
-rw-r--r--src/sensors/doc/snippets/sensorgestures/creating.cpp72
-rw-r--r--src/sensors/doc/snippets/sensorgestures/main.cpp44
-rw-r--r--src/sensors/doc/snippets/sensorgestures/myplugin.h82
-rw-r--r--src/sensors/doc/snippets/sensorgestures/plugin.cpp99
-rw-r--r--src/sensors/doc/snippets/sensorgestures/sensorgestures.pro8
-rw-r--r--src/sensors/doc/snippets/sensors/CMakeLists.txt32
-rw-r--r--src/sensors/doc/snippets/sensors/creating.cpp44
-rw-r--r--src/sensors/doc/snippets/sensors/main.cpp40
-rw-r--r--src/sensors/doc/snippets/sensors/mybackend.h40
-rw-r--r--src/sensors/doc/snippets/sensors/plugin.cpp42
-rw-r--r--src/sensors/doc/snippets/sensors/sensors.pro10
-rw-r--r--src/sensors/doc/snippets/sensors/start.cpp84
-rw-r--r--src/sensors/doc/snippets/sensors/tutorial.cpp25
-rw-r--r--src/sensors/doc/snippets/snippets.pro5
14 files changed, 111 insertions, 516 deletions
diff --git a/src/sensors/doc/snippets/sensorgestures/creating.cpp b/src/sensors/doc/snippets/sensorgestures/creating.cpp
deleted file mode 100644
index 78f7a737..00000000
--- a/src/sensors/doc/snippets/sensorgestures/creating.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QObject>
-#include <QString>
-#include <QSensorGestureManager>
-
-class MyObject : public QObject
-{
- void create();
-public slots:
- void gestureDetected(const QString &);
-};
-
-void MyObject::create()
-{
-//! [Receiving sensor gesture signals]
-
-// Create a QSensorGestureManager
- QSensorGestureManager gestureManager;
-
-// Get a list of known recognizers
- QStringList recognizersList = gestureManager.gestureIds();
-
-// Create a QSensorGeture object for each of those gesture recognizers
- QSensorGesture *gesture = new QSensorGesture( gestureManager.gestureIds(), this);
-// Connect the known signals up.
- connect(gesture, SIGNAL(detected(QString)), this, SLOT(gestureDetected(QString)));
-//! [Receiving sensor gesture signals]
-}
-
-void MyObject::gestureDetected(const QString &gesture)
-{
- Q_UNUSED(gesture);
-}
-
diff --git a/src/sensors/doc/snippets/sensorgestures/main.cpp b/src/sensors/doc/snippets/sensorgestures/main.cpp
deleted file mode 100644
index dee1ecb6..00000000
--- a/src/sensors/doc/snippets/sensorgestures/main.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-int main(int /*argc*/, char ** /*argv*/)
-{
- return 0;
-}
-
diff --git a/src/sensors/doc/snippets/sensorgestures/myplugin.h b/src/sensors/doc/snippets/sensorgestures/myplugin.h
deleted file mode 100644
index 0cf1a92b..00000000
--- a/src/sensors/doc/snippets/sensorgestures/myplugin.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MYPLUGIN_H
-#define MYPLUGIN_H
-
-#include <QObject>
-#include <qsensorgestureplugininterface.h>
-#include <qsensorgesturerecognizer.h>
-
-class MySensorGestureRecognizer : public QSensorGestureRecognizer
-{
- Q_OBJECT
- public:
-
- MySensorGestureRecognizer(QObject *parent = 0);
- ~MySensorGestureRecognizer();
-
- void create() override;
-
- QString id() const override;
- bool start() override;
- bool stop() override;
- bool isActive() override;
-
-Q_SIGNALS:
-// all signals will get exported to QSensorGesture
- void mySignal();
-};
-
-class MySensorGesturePlugin : public QObject, public QSensorGesturePluginInterface
-{
- Q_OBJECT
- //Q_PLUGIN_METADATA(IID "com.Nokia.QSensorGesturePluginInterface" FILE "plugin.json")
- Q_INTERFACES(QSensorGesturePluginInterface)
-public:
-
- explicit MySensorGesturePlugin();
- ~MySensorGesturePlugin();
-
- QList<QSensorGestureRecognizer *> createRecognizers() override;
- QStringList supportedIds() const override;
- QString name() const override { return "MyGestures"; }
-};
-
-#endif
diff --git a/src/sensors/doc/snippets/sensorgestures/plugin.cpp b/src/sensors/doc/snippets/sensorgestures/plugin.cpp
deleted file mode 100644
index a94a188e..00000000
--- a/src/sensors/doc/snippets/sensorgestures/plugin.cpp
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "myplugin.h"
-
-#include <qsensorgestureplugininterface.h>
-#include <qsensorgesturemanager.h>
-
-//! [Plugin]
-
-MySensorGestureRecognizer::MySensorGestureRecognizer(QObject *parent)
- : QSensorGestureRecognizer(parent)
-{
-}
-
-MySensorGestureRecognizer::~MySensorGestureRecognizer()
-{
-}
-
-bool MySensorGestureRecognizer::start()
-{
- Q_EMIT mySignal();
- return true;
-}
-
-bool MySensorGestureRecognizer::stop()
-{
- return true;
-}
-
-bool MySensorGestureRecognizer::isActive()
-{
- return true;
-}
-
-void MySensorGestureRecognizer::create()
-{
-}
-
-QString MySensorGestureRecognizer::id() const
-{
- return QString("QtSensors.mygestures");
-}
-
-
-MySensorGesturePlugin::MySensorGesturePlugin(){}
-MySensorGesturePlugin::~MySensorGesturePlugin(){}
-
-QList <QSensorGestureRecognizer *> MySensorGesturePlugin::createRecognizers()
-{
- QList <QSensorGestureRecognizer *> recognizers;
- MySensorGestureRecognizer *recognizer = new MySensorGestureRecognizer(this);
- recognizers.append(recognizer);
-
- return recognizers;
-}
-
-QStringList MySensorGesturePlugin::supportedIds() const
-{
- return QStringList() << "QtSensors.mygestures";
-}
-
-//! [Plugin]
diff --git a/src/sensors/doc/snippets/sensorgestures/sensorgestures.pro b/src/sensors/doc/snippets/sensorgestures/sensorgestures.pro
deleted file mode 100644
index 7442dd87..00000000
--- a/src/sensors/doc/snippets/sensorgestures/sensorgestures.pro
+++ /dev/null
@@ -1,8 +0,0 @@
-TEMPLATE=app
-TARGET=sensorgesturessdocsnippet
-QT = core sensors
-SOURCES+=main.cpp\
- creating.cpp\
- plugin.cpp
-HEADERS+=myplugin.h
-!win32:*g++*:LIBS+=-rdynamic
diff --git a/src/sensors/doc/snippets/sensors/CMakeLists.txt b/src/sensors/doc/snippets/sensors/CMakeLists.txt
new file mode 100644
index 00000000..27480020
--- /dev/null
+++ b/src/sensors/doc/snippets/sensors/CMakeLists.txt
@@ -0,0 +1,32 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+cmake_minimum_required(VERSION 3.16)
+project(sensorsdocsnippet LANGUAGES CXX)
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+find_package(Qt6 COMPONENTS Core Sensors)
+
+qt_add_executable(sensorsdocsnippet
+ creating.cpp
+ main.cpp
+ mybackend.h
+ plugin.cpp
+ start.cpp
+)
+
+target_link_libraries(sensorsdocsnippet PUBLIC
+ Qt::Sensors
+)
+
+if (GCC AND UNIX)
+ target_link_libraries(sensorsdocsnippet PUBLIC
+ rdynamic
+ log
+ )
+endif()
diff --git a/src/sensors/doc/snippets/sensors/creating.cpp b/src/sensors/doc/snippets/sensors/creating.cpp
index 4a5ef06d..4c99066f 100644
--- a/src/sensors/doc/snippets/sensors/creating.cpp
+++ b/src/sensors/doc/snippets/sensors/creating.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QObject>
#include <qaccelerometer.h>
@@ -57,7 +21,7 @@ QAccelerometer *sensor = new QAccelerometer(this);
QOrientationSensor orient_sensor;
//! [Creating a sensor]
- Q_UNUSED(sensor)
+ Q_UNUSED(sensor);
Q_UNUSED(orient_sensor);
{
@@ -69,7 +33,7 @@ Q_UNUSED(magnetometer);
{
//! [3]
-QSensor *magnetometer = new QSensor(QMagnetometer::type, this);
+QSensor *magnetometer = new QSensor(QMagnetometer::sensorType, this);
//! [3]
Q_UNUSED(magnetometer);
}
diff --git a/src/sensors/doc/snippets/sensors/main.cpp b/src/sensors/doc/snippets/sensors/main.cpp
index dee1ecb6..fb6724d5 100644
--- a/src/sensors/doc/snippets/sensors/main.cpp
+++ b/src/sensors/doc/snippets/sensors/main.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
int main(int /*argc*/, char ** /*argv*/)
{
diff --git a/src/sensors/doc/snippets/sensors/mybackend.h b/src/sensors/doc/snippets/sensors/mybackend.h
index 59c54069..b964e747 100644
--- a/src/sensors/doc/snippets/sensors/mybackend.h
+++ b/src/sensors/doc/snippets/sensors/mybackend.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef MYBACKEND_H
#define MYBACKEND_H
diff --git a/src/sensors/doc/snippets/sensors/plugin.cpp b/src/sensors/doc/snippets/sensors/plugin.cpp
index 1eef5966..27f50d72 100644
--- a/src/sensors/doc/snippets/sensors/plugin.cpp
+++ b/src/sensors/doc/snippets/sensors/plugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "mybackend.h"
#include <qsensorplugin.h>
@@ -52,7 +16,7 @@ class MyPluginClass : public QObject, public QSensorPluginInterface, public QSen
public:
void registerSensors() override
{
- QSensorManager::registerBackend(QAccelerometer::type, MyBackend::id, this);
+ QSensorManager::registerBackend(QAccelerometer::sensorType, MyBackend::id, this);
}
QSensorBackend *createBackend(QSensor *sensor) override
diff --git a/src/sensors/doc/snippets/sensors/sensors.pro b/src/sensors/doc/snippets/sensors/sensors.pro
deleted file mode 100644
index 91d49772..00000000
--- a/src/sensors/doc/snippets/sensors/sensors.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE=app
-TARGET=sensorsdocsnippet
-QT = core sensors
-SOURCES+=main.cpp\
- creating.cpp\
- start.cpp\
- plugin.cpp
-HEADERS+=mybackend.h
-!win32:*g++*:LIBS+=-rdynamic
-OTHER_FILES += *.qml
diff --git a/src/sensors/doc/snippets/sensors/start.cpp b/src/sensors/doc/snippets/sensors/start.cpp
index 3ac5b50e..18c87d06 100644
--- a/src/sensors/doc/snippets/sensors/start.cpp
+++ b/src/sensors/doc/snippets/sensors/start.cpp
@@ -1,43 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtSensors module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-#include <qsensor.h>
+#include <QtSensors/qsensor.h>
+#include <QtCore/QMetaObject>
+#include <QtCore/QMetaproperty>
void start()
{
@@ -52,6 +18,42 @@ qreal x = reading->property("x").value<qreal>();
qreal y = reading->value(1).value<qreal>();
//! [Starting a sensor]
- Q_UNUSED(x)
- Q_UNUSED(y)
+ Q_UNUSED(x);
+ Q_UNUSED(y);
}
+
+class MyObject : public QObject
+{
+ void findSensors()
+ {
+ //! [Find sensors]
+ QList<QSensor*> mySensorList;
+ for (const QByteArray &type : QSensor::sensorTypes()) {
+ qDebug() << "Found a sensor type:" << type;
+ for (const QByteArray &identifier : QSensor::sensorsForType(type)) {
+ qDebug() << " " << "Found a sensor of that type:" << identifier;
+ QSensor* sensor = new QSensor(type, this);
+ sensor->setIdentifier(identifier);
+ mySensorList.append(sensor);
+ }
+ }
+ //! [Find sensors]
+ //! [Print reading properties]
+ for (QSensor* sensor : mySensorList) {
+ const int firstProperty = QSensorReading::staticMetaObject.propertyOffset();
+ // Connect to backend first in case start() hasn't been called yet
+ if (!sensor->connectToBackend())
+ continue;
+ qDebug() << "Sensor" << sensor->identifier() << "reading properties:";
+ QSensorReading *reading = sensor->reading();
+ if (reading) {
+ const QMetaObject *mo = reading->metaObject();
+ for (int i = firstProperty; i < mo->propertyCount(); ++i) {
+ QByteArray name = mo->property(i).name();
+ qDebug() << " " << name << reading->property(name).toByteArray();
+ }
+ }
+ }
+ //! [Print reading properties]
+ }
+};
diff --git a/src/sensors/doc/snippets/sensors/tutorial.cpp b/src/sensors/doc/snippets/sensors/tutorial.cpp
new file mode 100644
index 00000000..e8714961
--- /dev/null
+++ b/src/sensors/doc/snippets/sensors/tutorial.cpp
@@ -0,0 +1,25 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//! [MySensor]
+class MyReadingPrivate;
+
+class MyReading : public QSensorReading
+ {
+ Q_OBJECT
+ Q_PROPERTY(qreal myprop READ myprop)
+ DECLARE_READING(MyReading)
+public:
+ qreal myprop() const;
+ void setMyprop(qreal myprop);
+ };
+
+class MySensor : public QSensor
+{
+ Q_OBJECT
+public:
+ explicit MySensor(QObject *parent = 0);
+ MyReading *reading() const;
+ static char const * const sensorType;
+ };
+//! [MySensor]
diff --git a/src/sensors/doc/snippets/snippets.pro b/src/sensors/doc/snippets/snippets.pro
deleted file mode 100644
index f73d4a35..00000000
--- a/src/sensors/doc/snippets/snippets.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += sensors
-SUBDIRS += sensorgestures
-