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

    Row{
    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.

    http://developer.qt.nokia.com/doc/qt-4.7/richtext-html-subset.html#id-328df859-3724-4e22-90ef-a4d978acce54

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.