天天看點

Qt基于Qml超連結使用

示範效果 

Qt基于Qml超連結使用
hoverEnabled: true;//滑鼠在控件範圍内
cursorShape: (containsMouse? Qt.PointingHandCursor: Qt.ArrowCursor);//顯示手式滑鼠      
onClicked: Qt.openUrlExternally
) //打開URL      
import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12

ApplicationWindow {
    visible: true
    width: 400
    height: 400
    title: qsTr("Qt基于Qml超連結使用")

    Rectangle {
        width: 100
        height: 50
        anchors.centerIn: parent
        color: "lightblue"
        radius: 10
        Text {
            anchors.centerIn: parent
            text: '<html></style><a href=
            ">打開CSDN</a></html>'
            MouseArea {
               anchors.fill: parent;
               hoverEnabled: true;//滑鼠在控件範圍内
               cursorShape: (containsMouse? Qt.PointingHandCursor: Qt.ArrowCursor);//顯示手式滑鼠
               onClicked: Qt.openUrlExternall
               //打開URL
           }
        }

    }
}      

繼續閱讀