Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.8, 6.3.2
-
None
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.