나만의 센서 만들기
Qt Sensors 모듈은 QML 및 C++ 인터페이스를 통해 센서 하드웨어에 접근할 수 있도록 지원합니다.
이 API는 Android, iOS 및 Windows(MSVC)에서 지원됩니다.
C++ API를 사용하여 나만의 센서 만들기
Qt 모듈의 C++ API를 사용하려면 모듈 라이브러리를 직접 또는 다른 종속성을 통해 링크해야 합니다.
센서 만들기
사용자 정의 센서를 생성하려면 다음 단계를 따르십시오.
- 사용자 정의 MySensor 및 MySensorReading 클래스 생성
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; }; - 다음 클래스를 상속받아 MySensorBackend를 생성합니다. QSensorBackend
- 해당 백엔드를 인스턴스화하기 위해 MySensorBackendFactory 팩토리 클래스를 상속하여 생성합니다 QSensorBackendFactory
- QSensorManager::registerBackend ("MySensorType", "MySensorId", &myfactory)를 호출하여 백엔드 팩토리를 등록합니다
- 새로운 MySensor를 인스턴스화하고 사용을 시작하세요
또 다른 옵션으로, 센서를 필요에 따라 사용할 수 있는 센서 플러그인을 생성하는 방법도 있습니다.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.