Qml超链接

作者: zhengtianzuo | 来源:发表于2018-11-29 20:19 被阅读0次
Text {
            anchors.centerIn: parent
            text: '<html></style><a href="http://www.baidu.com">点击</a></html>'
            MouseArea {
               anchors.fill: parent;
               hoverEnabled: true;
               cursorShape:
                   (containsMouse? Qt.PointingHandCursor: Qt.ArrowCursor);
               onClicked: Qt.openUrlExternally("http://www.baidu.com")
           }
        }

文本使用html超链接显示, 被点击的时候调用Qt.openUrlExternally来使用默认应用打开超链接

show.gif

需要完整代码请访问QtQuickExamples

相关文章

网友评论

    本文标题:Qml超链接

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