Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Click to change the color of the hyperlink
Qt 6.11 is out! See what's new in the release blog

Click to change the color of the hyperlink

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 4.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    harlentan
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Diph
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved