Qml弹出菜单

作者: zhengtianzuo | 来源:发表于2018-11-29 20:21 被阅读0次

    主要是对菜单项的一个自定义:

                MenuItem {
                    id: menuItem1
                    anchors.left: parent.left
                    anchors.leftMargin: 6
                    text: qsTr("在线")
                    height: 24
                    indicator:
                    Image {
                        id: image1
                        height: 16
                        width: 16
                        anchors.verticalCenter: parent.verticalCenter
                        source: "qrc:/images/online.png"
                    }
                    contentItem: Text {
                        id: text1
                        text: menuItem1.text
                        font: menuItem1.font
                        opacity: enabled ? 1.0 : 0.3
                        color: menuItem1.down ? "#AA0000" : "#148014"
                        horizontalAlignment: Text.AlignLeft
                        verticalAlignment: Text.AlignVCenter
                        leftPadding: menuItem1.indicator.width
                    }
                    onTriggered: {image.source = image1.source;window.visible = false;console.debug("状态切换 在线")}
                }
    
    show.gif

    需要完整代码请访问QtQuickExamples

    相关文章

      网友评论

        本文标题:Qml弹出菜单

        本文链接:https://www.haomeiwen.com/subject/yckqcqtx.html