Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.2.1, 5.9.0, 5.10.1
-
Windows / Linux / macOS
Description
When HTML content is set as a QLabel text, it starts painting the wrong background (presumably, inherited from the containing widget) instead of the transparent. It's noticeable when using non-solid (gradient, pixmap, etc.) backgrounds in parents.
// Main Window: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { resize(400, 300); GradientWidget *widget = new GradientWidget; setCentralWidget(widget); QVBoxLayout *layout = new QVBoxLayout(widget); layout->addWidget(new QLabel("Label with a proper (transparent) background")); layout->addWidget(new QLabel("<b>HTML</b> label with an <i>improper</i> (inherited from parent) background")); } // Gradient Widget: class GradientWidget : public QWidget { protected: void paintEvent(QPaintEvent *event) { QLinearGradient gradient(event->rect().topLeft(), event->rect().bottomRight()); gradient.setColorAt(0, Qt::white); gradient.setColorAt(1, Qt::darkYellow); QPainter painter(this); painter.fillRect(event->rect(), gradient); } };