QOrientationReading Class
QOrientationReading 类表示来自方位传感器的一次读数。更多内容...
| 头文件: | #include <QOrientationReading> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Sensors) target_link_libraries(mytarget PRIVATE Qt6::Sensors) |
| qmake: | QT += sensors |
| 继承自: | QSensorReading |
公共类型
| enum | Orientation { Undefined, TopUp, TopDown, LeftUp, RightUp, …, FaceDown } |
属性
- orientation : Orientation
公共函数
| QOrientationReading::Orientation | orientation() const |
| void | setOrientation(QOrientationReading::Orientation orientation) |
详细说明
方向传感器报告设备的朝向。由于其在用户界面(UI)层级之下运行,因此不会报告用户界面的旋转情况,甚至无法知晓用户界面的旋转状态。最重要的是,这意味着该传感器无法用于检测设备处于纵向还是横向模式。
该传感器可用于检测设备的特定一侧是否朝上。
QOrientationReading 单位
方向传感器使用QOrientationReading::Orientation 枚举中的预定义值返回设备的方向。
成员类型文档
enum QOrientationReading::Orientation
此枚举表示设备的方向。
要解释每个值的含义,参考下图会很有帮助。

此处显示的朝向顺序为:TopUp、TopDown、LeftUp、RightUp、FaceUp、FaceDown。

| 常量 | 值 | 描述 |
|---|---|---|
QOrientationReading::Undefined | 0 | 方向未知。 |
QOrientationReading::TopUp | 1 | 设备的顶部边缘朝上。 |
QOrientationReading::TopDown | 2 | 设备的顶部边缘朝下。 |
QOrientationReading::LeftUp | 3 | 设备的左侧边缘朝上。 |
QOrientationReading::RightUp | 4 | 设备的右侧边缘朝上。 |
QOrientationReading::FaceUp | 5 | 设备的正面朝上。 |
QOrientationReading::FaceDown | 6 | 设备的正面朝下。 |
需要注意的是,方向传感器报告的是设备的朝向,而非用户界面的朝向。设备的朝向不会仅仅因为用户界面被旋转而改变。这意味着该传感器无法用于检测设备处于纵向还是横向模式。
属性文档
[read-only] orientation : Orientation
该属性存储设备的方向。
其单位为描述设备方向的枚举类型。
访问函数:
| QOrientationReading::Orientation | orientation() const |
另请参阅 QOrientationReading Units 。
成员函数文档
void QOrientationReading::setOrientation(QOrientationReading::Orientation orientation)
设置读取操作的orientation 。
另请参阅 orientation()。
© 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.