QSensorReading Class
QSensorReading 클래스는 센서의 판독값을 보관합니다. 더 보기...
헤더: | #include <QSensorReading> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Sensors) target_link_libraries(mytarget PRIVATE Qt6::Sensors) |
qmake: | QT += sensors |
상속합니다: | QObject |
상속 대상: |
속성
- timestamp : const quint64
공용 함수
void | setTimestamp(quint64 timestamp) |
quint64 | timestamp() const |
QVariant | value(int index) const |
int | valueCount() const |
매크로
DECLARE_READING(classname) | |
IMPLEMENT_READING(classname) |
속성 문서
[read-only]
timestamp : const quint64
이 속성은 판독값의 타임스탬프를 보유합니다.
타임스탬프 값은 고정점 이후 마이크로초 단위입니다. 타임스탬프를 사용하여 두 센서 판독값이 얼마나 떨어져 있는지 확인할 수 있습니다.
서로 다른 센서의 센서 타임스탬프는 참조용으로 다른 고정점을 선택할 수 있으므로 직접 비교하지 못할 수도 있다는 점에 유의하세요.
일부 플랫폼에서는 타임스탬프가 제대로 전달되지 않을 수 있습니다. 애플리케이션은 간혹 타임스탬프가 뒤로 이동하는 문제에 대비해야 합니다.
액세스 함수:
quint64 | timestamp() const |
멤버 함수 문서
void QSensorReading::setTimestamp(quint64 timestamp)
판독값의 timestamp 을 설정합니다.
timestamp()도 참조하세요 .
quint64 QSensorReading::timestamp() const
판독값의 타임스탬프를 반환합니다.
참고: 속성 타임스탬프에 대한 게터 함수입니다.
setTimestamp()도 참조하세요 .
QVariant QSensorReading::value(int index) const
index 에서 속성 값을 반환합니다.
이 함수는 데이터 함수를 직접 호출하는 것보다 느리다는 점에 유의하세요.
다음은 사용 가능한 다른 메커니즘을 통해 프로퍼티를 가져오는 예제입니다.
직접 액세스하는 것이 가장 좋은 성능을 제공하지만 액세스하는 데이터에 대한 컴파일 타임 지식이 필요합니다.
QAccelerometerReading *reading = ...; qreal x = reading->x();
이름으로 프로퍼티에 액세스할 수도 있습니다. 이렇게 하려면 QObject::property()를 호출해야 합니다.
마지막으로 숫자 인덱스를 통해 값에 액세스할 수 있습니다.
value()는 QSensorReading 의 하위 클래스에서 Q_PROPERTY()로 선언된 프로퍼티에만 액세스할 수 있습니다.
valueCount() 및 QObject::property()도 참조하세요 .
int QSensorReading::valueCount() const
판독값에 있는 추가 속성 수를 반환합니다.
QSensorReading 에 선언된 프로퍼티는 계산되지 않습니다.
예를 들어 QAccelerometerReading 의 경우 해당 클래스에 정의된 프로퍼티가 3개이므로 3을 반환합니다.
매크로 문서
DECLARE_READING(classname)
DECLARE_READING 매크로는 읽기 클래스에 몇 가지 필수 메서드를 추가합니다.
이 매크로는 모든 읽기 클래스에 사용해야 합니다. 읽기 클래스의 classname 을 전달합니다.
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); };
IMPLEMENT_READING()도 참조하세요 .
IMPLEMENT_READING(classname)
IMPLEMENT_READING 매크로는 읽기 클래스에 필요한 메서드를 구현합니다.
이 매크로는 모든 읽기 클래스에 사용해야 합니다. 헤더 파일이 아닌 단일 컴파일 단위(소스 파일)에 배치해야 합니다. 읽기 클래스의 classname 을 전달합니다.
IMPLEMENT_READING(MyReading)
DECLARE_READING()도 참조하세요 .
© 2025 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.