我正在尝试ProximitySensor在 QML 中使用。我没有找到如何使用它的示例。我正在使用 QtSensors 5.0。我尝试通过调用该属性来获取附近是否有东西reading,但该属性只有以下属性deleteLater:objectName和timestamp。我试过这个ProximityReading.near,但它返回未定义。我也试过这个proximitySensor.close(),但它返回未定义proximitySensor。接近传感器工作正常,因为我在智能手机中测试了属性reading.timestamp并且值已正确更新。
我的代码是这样的:
import QtSensors 5.0
ProximitySensor {
id: proximity
active: true
dataRate: 100
onReadingChanged: {
// How do I get if something is near?
}
onErrorChanged: {
}
}