qml 设置tooltip,Customizing ToolTip

时间:2021-05-06 11:06:20

Button {
            id: btn
            text: "Tip"
            anchors.horizontalCenter: parent.horizontalCenter

//            ToolTip.timeout: 5000
//            ToolTip.visible: pressed
//            ToolTip.text: "This is a tool tip."

ToolTip {
                id: control
                visible: btn.pressed
                ToolTip.timeout: 5000
                text: qsTr("A descriptive tool tip of what the button does")

contentItem: Text {
                    text: control.text
                    font: control.font
                    color: "#21be2b"
                }

background: Rectangle {
                    border.color: "#21be2b"
                }
            }

}