Qt World Summit: Submit your Presentation

Click to change the color of the hyperlink

  • Hi,
    There is a hyperlink in my Text, and I want it to change the color when I click on it.
    But it seems no effect that I add some css in my code.

    import QtQuick 1.0

    Rectangle {
    id: redRect
    width: 400; height: 400
    color: "lightblue"

        Text {
            anchors.centerIn: parent
            id: htm
            font.bold: true
            text: '<html>'+
                  '<style type="text/css">'+
                  'a:link {color: #000;text-decoration: none;}'+
                  'a:active {color: #bc2931;text-decoration: none;}</style><body>'+
                  '<a href="www.google.com.hk">website</a>.click to do something&lt;/body&gt;&lt;/html>'
            textFormat: Text.RichText
            onLinkActivated: {console.log(link)}


    The color of the website never changed. I wonder if the QML support this feature.

  • It's not supported.


    All CSS 2.1 selector classes are supported except pseudo-class selectors such as :first-child, :visited and :hover.

Log in to reply