c++ - 依次加载多个 QML 弹出窗口组件
问题描述
收到信号后,我正在尝试在嵌入式屏幕上加载弹出窗口。为了模拟这一点,我创建了属性,当每个属性的值为 1 时,应该为每个属性显示一个弹出窗口。但是,当我有多个值为 1 的属性时,它只会加载第一个弹出窗口并停在那里。
这是从 PopUp 组件加载的屏幕上的代码
Loader{
id: loader
PopUp {state: 'emptystate'}
}
这是代码PopUp.qml
import QtQuick 2.9
Rectangle {
id: popupContainer
border.color: '#cccccc'
width: 423
height: 82
x: 749
y: 498
color: 'transparent'
border.width: 2
radius: 20
// font loader
FontLoader {id: titleFont; source: "font/orbitron-medium.ttf"}
FontLoader {id: textFont; source: "font/futura-book-bt.ttf"}
// properties
property alias popUpIndicator : pindicator.source
property alias popUpTitle : ptitle.text
property alias popUpMessage : pmessage.text
Image {
id: pindicator
x: 49
y: 8
width: 66
height: 66
verticalAlignment: parent.verticalCenter
}
Rectangle {
id: messages
Text {
id: ptitle
y: 15
color: '#cccccc'
font.family: titleFont.name
font.capitalization: Font.AllUppercase
font.pixelSize: 17
anchors.leftMargin: 125
anchors.left: messages.left
}
Text {
id: pmessage
y: 40
color: '#cccccc'
font.family: textFont.name
font.pixelSize: 18
anchors.leftMargin: 125
anchors.left: messages.left
}
}
SequentialAnimation {
NumberAnimation {target: popupContainer; properties: 'opacity'; from: 0.0; to: 1.0; duration: 3000; easing.type: Easing.Linear}
NumberAnimation {target: popupContainer; properties: 'opacity'; from: 1.0; to: 0.0; duration: 3000; easing.type: Easing.Linear}
running: true
}
// states
states: [
State {
name: 'emptystate'
PropertyChanges{target: popupContainer; border.color : 'transparent'}
},
State {
name: 'tyrepressure'
when: canTyrePressure == 1
PropertyChanges{target: popupContainer; popUpIndicator: "images/tyre.png"; popUpTitle : "Tyre Pressure Warning"; popUpMessage : "Check Tyre Pressure";}
},
State {
name: 'absmalfunction'
when: canABSMalfunction == 1
PropertyChanges{target: popupContainer; popUpIndicator: "images/abs.png"; popUpTitle : "ABS Malfunction"; popUpMessage : "Braking System Failure";}
},
State {
name: 'tpms'
when: canTPMS == 1
PropertyChanges{target: popupContainer; popUpIndicator: "images/tpms.png"; popUpTitle : "TPMS Malfunction"; popUpMessage : "Check TPM";}
},
State {
name: 'servicemode'
when: canServiceMode == 1
PropertyChanges{target: popupContainer; popUpIndicator: "images/servicemode.png"; popUpTitle : "Service Mode Active"; popUpMessage : "Service mode has been activated";}
},
State {
name: 'frontcollision'
when: canFrontCollision == 1
PropertyChanges{target: popupContainer; popUpIndicator: "images/frontcollision.png"; popUpTitle : "Front Collision Warning"; popUpMessage : "Front Collision Imminent: Slow Down";}
}
]
}
如何按顺序在屏幕上加载多个弹出组件?
解决方案
推荐阅读
- architecture - 如何在 RISC-V 中为 C.LD 压缩指令获取立即数/偏移位?
- java - 如何使用 mybatis 将数组值插入到 postgreSQL
- python - 从文本文件中读取多个 url 并使用 pycurl 查找 RESOLVE 结果
- node.js - Node version problem with Yarn and typescript
- reactjs - 如何在 React Table 中再次获取数据?
- javascript - 无法使用 Ajax 从控制器和数据库中的视图中获取 $id 变量
- android - AWS 登录问题 - 登录期间无法联合令牌 java.lang.RuntimeException:联合令牌时出错。- Android
- vba - 清除内容vba
- python - 如何在循环中的python代码中添加日志信息
- ruby-on-rails - 如何在 Rails 6 中集成 CKEditor?