气候控制QML示例
示例演示了如何从QML访问气候控制。
示例演示了如何从QML访问气候控制。
在示例中,《气候控制》被创建并启用了自动发现。当自动发现被启用时,模块开始搜索实现《QIviClimateControlBackendInterface》的插件存在性。
ClimateControl { id: climateControl discoveryMode: ClimateControl.LoadOnlySimulationBackends }
注意:为了简化部署过程,此示例加载了一个模拟的后端。
如果发现失败,将显示消息对话框
Component.onCompleted: { if (!climateControl.isValid) messageDialog.open() }
由于气候系统可以支持多个气候区域,因此我们需要区分这些区域。一个通用区域可以使用应用于所有区域的设置。
通用的《气候控制》属性值如下处理在复选框中
GroupBox { title: "Air Flow Direction" ColumnLayout { anchors.fill: parent CheckBox { text: "Windshield" checked: climateControl.airflowDirections & ClimateControl.Windshield onClicked: { if (checked) climateControl.airflowDirections |= ClimateControl.Windshield else climateControl.airflowDirections &= ~ClimateControl.Windshield } } CheckBox { text: "Dashboard" checked: climateControl.airflowDirections & ClimateControl.Dashboard onClicked: { if (checked) climateControl.airflowDirections |= ClimateControl.Dashboard else climateControl.airflowDirections &= ~ClimateControl.Dashboard } } CheckBox { text: "Floor" checked: climateControl.airflowDirections & ClimateControl.Floor onClicked: { if (checked) climateControl.airflowDirections |= ClimateControl.Floor else climateControl.airflowDirections &= ~ClimateControl.Floor } } } } CheckBox { text: "Air Condition" checked: climateControl.airConditioningEnabled onClicked: { climateControl.airConditioningEnabled = checked } } CheckBox { text: "Heater" checked: climateControl.heaterEnabled onClicked: { climateControl.heaterEnabled = checked } } CheckBox { text: "Air Recirculation" checked: climateControl.recirculationMode === ClimateControl.RecirculationOn onClicked: { if (checked) climateControl.recirculationMode = ClimateControl.RecirculationOn else climateControl.recirculationMode = ClimateControl.RecirculationOff } } ColumnLayout { RowLayout { Label { text: "Fan Speed" } SpinBox { value: climateControl.fanSpeedLevel onValueChanged: { climateControl.fanSpeedLevel = value } } } RowLayout { Label { text: "Steering Wheel Heater" } SpinBox { value: climateControl.steeringWheelHeater onValueChanged: { climateControl.steeringWheelHeater = value } } } }
对于分区的《气候控制》,使用《zoneAt》属性来控制来自 frontend 左气候区域的值
GroupBox { title: "Front Left Zone" ColumnLayout { RowLayout { Label { text: "Temperature" } SpinBox { value: climateControl.zoneAt.FrontLeft.targetTemperature onValueChanged: { climateControl.zoneAt.FrontLeft.targetTemperature = value } } } RowLayout { Label { text: "Seat Heater" } SpinBox { value: climateControl.zoneAt.FrontLeft.seatHeater onValueChanged: { climateControl.zoneAt.FrontLeft.seatHeater = value } } } } } GroupBox { title: "Front Right Zone" ColumnLayout { RowLayout { Label { text: "Temperature" } SpinBox { value: climateControl.zoneAt.FrontRight.targetTemperature onValueChanged: { climateControl.zoneAt.FrontRight.targetTemperature = value } } } RowLayout { Label { text: "Seat Heater" } SpinBox { value: climateControl.zoneAt.FrontRight.seatHeater onValueChanged: { climateControl.zoneAt.FrontRight.seatHeater = value } } } } } GroupBox { title: "Rear Zone" ColumnLayout { RowLayout { Label { text: "Temperature" } SpinBox { value: climateControl.zoneAt.Rear.targetTemperature onValueChanged: { climateControl.zoneAt.Rear.targetTemperature = value } } } RowLayout { Label { text: "Seat Heater" } SpinBox { value: climateControl.zoneAt.Rear.seatHeater onValueChanged: { climateControl.zoneAt.Rear.seatHeater = value } } } } }
©2020 The Qt Company Ltd. 本文档中包含的文档贡献是各自所有者的版权。本提供的文档根据免费软件基金会的GNU自由文档许可协议版本1.3条款许可。Qt及其相应标志是The Qt Company Ltd在芬兰以及/或全球的其他国家的商标。所有其他商标均为其各自所有者的财产。