用Popup仿MessageBox 支持HTML语法混排


Popup {
    property var subtext: ""
    property var subtitle: ""
    id: messsagebox2
    x: 0
    y: 0
    padding: 0
    background: Item{}
    //是否使用popup背景
    //              dim:false
    width: parent.width
    height: parent.height
    modal: true
    focus: true
    closePolicy: Popup.NoAutoClose

    Rectangle {
        id: pp
        width: parent.width*0.8
        height: parent.height/2
        anchors.centerIn: parent
        color: "#35C47F"
        radius: 5
        clip: true
        Old.ScrollView {
            id:flck
            width: parent.width
            height: parent.height -mok.height
            Column{
                id:col

                Text{
                    id:title
                    text:subtitle
                    font.pointSize: 24
                    verticalAlignment: Text.AlignVCenter
                    padding: 15
                    width: parent.width
                    height: 40
                    color: "#FAFCF7"
                    wrapMode: Text.WrapAnywhere
                    textFormat: Text.RichText
                    BorderImage {
                        id:closeimg
                        source: "qrc:/HelpUI/res/XX.bmp"
                        width: 24; height: 24
                        border.left: 1; border.top: 1
                        border.right: 1; border.bottom: 1
                        x:title.width - width - 5
                        y:title.height/2 - height/2
                        MouseArea{
                            anchors.fill: parent
                            onClicked: {
                                messsagebox2.close();
                            }
                        }
                        Timer{
                            id:tttest
                            running: messsagebox2.visible
                            repeat: true
                            interval: 2000
                            triggeredOnStart: true//第一次先主动触发一次onTriggered
                            onTriggered: {
                                console.log("**one  time***")
                                dh.restart()
                                mok.width=Math.random()*mok.height*1.7+mok.height*1.5

                            }
                        }
                        NumberAnimation {
                            id:dh
                            target: closeimg
                            running: messsagebox2.visible
                            property: "rotation"
                            from:0
                            to:360
                            loops:1/*AnimatedSprite.Infinite*/
                            duration: 500
                            easing.type: Easing.InOutQuad
                        }
                    }
                }
                Rectangle{width: parent.width*0.75;height: 2;color: "#27AE61"}

                //内容
                Text{
                    id: txt
                    text: subtext
                    font.pixelSize: 16
                    font.bold: true
                    //                    verticalAlignment: Text.AlignVCenter
                    //                    horizontalAlignment: Text.AlignHCenter
                    color: "#FAFCF7"
                    width: flck.width
                    wrapMode: Text.WrapAnywhere
                    textFormat: Text.RichText
                }

            }

        }

        //确定按钮
        Button{
            id:mok
            //居中
            x:pp.width/2 -width/2
            anchors.top: flck.bottom
            width: height*1.5

            height:60
            text: "确定"
            Material.background:"#35C37F"
            Material.foreground:"#FAFCF7"
            onClicked: {
                messsagebox2.close();
            }
            Behavior on width {
                NumberAnimation{ duration: 2000; easing.type: Easing.OutInBounce}
            }


        }



        layer.enabled: true
        layer.effect: DropShadow {
            transparentBorder: true//绘制边框阴影
            color: "#80000000";
            radius: 30.0;
            id:drop;

            //cached: true;
            horizontalOffset: 0;
            verticalOffset: 0;
            samples: 16;
            smooth: true;
        }
    }
    function msg(title , txt)
    {
        subtitle = title;
        subtext = txt;
        messsagebox2.open();
    }



}

这里写图片描述

    MyMessageBox{
        id:gobalMsg
    }
    function  gMessage(title,txt)
    {
        gobalMsg.msg(title,txt)
    }
   gMessage("错误","<img align='middle' src='qrc:/image/TipIcon/warning.png' width='24' height='24' \>账号密码长度不正确")
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值