qt qml Qt popup属性配置 popup编写

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")}
                }
            }
        }

    }

popupgif图

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值