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

QML RichText table cell backgrounds include padding

    XMLWordPrintable

Details

    Description

      When setting a background color for a cell (td or th) in a Qml rich text element, only the area inside of the padding is colored. Browsers color the whole cell. This makes it impossible to have alternating row colors without weird margins between the elements, when you add padding around the table cells.

      Example:

      import QtQuick
      import QtQuick.Window
      
      Window {
          visible: true
          width: 400
          height: 200
          title: qsTr("richtextbugs")
      
          Text {
              anchors.fill: parent
              textFormat: Text.RichText
              wrapMode: Text.Wrap
      
             text: `
      <style>
      table {
      	width:100%;
          border-width: 1px;
          border-collapse: collapse;
      }
      table th,
      table td {
      border: 1px solid black;
      padding: 3px;
      background-color: "red";
      }
      </style>
      
      <table>
        <tr>
          <th>Firstname</th>
          <th>Lastname</th> 
          <th>Age</th>
        </tr>
        <tr>
          <td>Jill</td>
          <td>Smith</td>
          <td>50</td>
        </tr>
        <tr>
          <td>Eve</td>
          <td>Jackson</td>
          <td>94</td>
        </tr>
        <tr>
          <td>John</td>
          <td>Doe</td>
          <td>80</td>
        </tr>
      </table>
      `
          }
      }
      

      Originally the background colors were added in https://bugreports.qt.io/browse/QTBUG-72457 / https://codereview.qt-project.org/c/qt/qtdeclarative/+/254583, but the calculated blockBoundingRect is without the padding of the cell, so when a padding is set, it is too small.

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            deepbluev7 Nicolas Werner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes