summaryrefslogtreecommitdiff
path: root/src/sensors/doc/snippets/sensors/start.cpp
blob: 2ff9c89c541a0b0ac55e09714d4d3f76f238eede (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include <qsensor.h>

void start()
{
//! [Starting a sensor]
// start the sensor
QSensor sensor("QAccelerometer");
sensor.start();

// later
QSensorReading *reading = sensor.reading();
qreal x = reading->property("x").value<qreal>();
qreal y = reading->value(1).value<qreal>();
//! [Starting a sensor]

    Q_UNUSED(x);
    Q_UNUSED(y);
}