Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-76137

QML Text background rendered black with style=background-color: transparent

    XMLWordPrintable

Details

    • 35acc9fc3c41446bacbbfe754f7f494de7f62411 (qt/qtdeclarative/5.12)

    Description

      Setting a HTML element background-color to transparent in a Text causes the element background to be rendered entirely black instead of transparent. Opacity seems to work perfectly fine as long as it is >= 1%. The behavior with a TextEdit appears identical.

      Steps to reproduce:

      Run the example below & click on the window to toggle sample text background-color opacity between 1% to 0%.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
          visible: true
          width: 640
          height: 240
          title: qsTr("Hello World")
      
          MouseArea{
              anchors.fill: parent
              onClicked: {
                  exampleText.transparentBackground = !exampleText.transparentBackground
                  console.log("Text.text set to: " + exampleText.text)
              }
          }
      
          Text {
      
              property string sampleText: "<h1 style=\"background-color:%1\"> Hello. I'm a H1.</h1>"
              property bool transparentBackground: false
      
              id: exampleText
      
              color: "orange"
              textFormat: Text.RichText
              text: transparentBackground ? sampleText.arg("rgba(255,255,255,0.00)") :
                                            sampleText.arg("rgba(255,255,255,0.01)")
      
              font.family: "Arial"
      
              anchors.verticalCenter: parent.verticalCenter
              anchors.horizontalCenter: parent.horizontalCenter
          }
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            miikapernu Miika Pernu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes