15.popup
z属性:默认页面最高 无论怎么设置
如果在控件里写 那么父控件的visble不会限制popup的visble,永远高于默认页面
closePolicy : enumeration popup的关闭条件
常用下面:
- Popup.NoAutoClose The popup will only close when manually instructed to do so.
- Popup.CloseOnPressOutside The popup will close when the mouse is pressed outside of it.
- Popup.CloseOnReleaseOutside The popup will close when the mouse is released outside of it.
modal : bool 模态:决定是否可以按popup父的界面
dim : bool 当非模态时,是否改变非popup的背景色
Overlay.modeless :可以重写编辑模态下的popup后面的背景 一般使用agba格式 有透明度来的 “1f00ff00” 如果想在里面设置按钮 需要外加popup才可以 因为父popup优先级高于所有控件 除了popup控件
Overlay.modeless:可以重写编辑非模态下的popup后面的背景
enter : Transition 进入的动画
exit : Transition 退出的动画
Popup {
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
}
Popup {
exit: Transition {
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
}
}
整个写好的例子
Scan_IconLabelButton是我自己的控件 你可以直接换成button
Popup{
id:tishi
anchors.centerIn: parent
width: 200
closePolicy: Popup.CloseOnPressOutside
modal: true
height: 200
exit: Transition {
NumberAnimation { property: "opacity"; from: 1.0; to: 0.0 }
}
enter: Transition {
NumberAnimation { property: "opacity"; from: 0.0; to: 1.0 }
}
contentItem: Rectangle{
anchors.fill: parent
color: "green"
ColumnLayout{
Scan_IconLabelButton{
implicitHeight: 35
implicitWidth: 120
text: qsTr("标志按钮")
backgroundColor: "black"
setIcon:"qrc:/Icons/MapIcons/saveLocation.svg"
smallBackgroundColor: "red"
}
Scan_IconLabelButton{
implicitHeight: 35
implicitWidth: 120
text: qsTr("标志按钮")
backgroundColor: "black"
setIcon:"qrc:/Icons/MapIcons/direction.svg"
smallBackgroundColor: palette.dark
}
}
}
Overlay.modal: Rectangle{
anchors.fill: parent
color: "#1f00ff00"
Popup{
visible: true
closePolicy: Popup.NoAutoClose
height: 200
width: 100
background: Rectangle{
color: "#00000000"
}
Button{
text: "开始"
anchors.centerIn: parent
onClicked: {
console.log("clicked")}
}
}
}
}