Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12, 5.15, 6.0.0
-
None
Description
Investigating another issue I bumped into this one. It seems our QLabel rich text support uses QTextHtmlParser when the label is rich text containing e.g. a <a href="">link</a>.
The problem is that the html parser flattens any color roles it finds, e.g. the link color, into concrete QColors. When the system or application palette then changes, the QLabel doesn't re-parse the rich text, so the new palette colors are not picked up.
#0 0x0000000101afa7f4 in QCss::Declaration::colorValue(QPalette const&) const at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qcssparser.cpp:1469 #1 0x0000000101910495 in QTextHtmlParserNode::applyCssDeclarations(QList<QCss::Declaration> const&, QTextDocument const*) at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtexthtmlparser.cpp:1214 #2 0x000000010190e2a6 in QTextHtmlParser::parseTag() at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtexthtmlparser.cpp:710 #3 0x000000010190db55 in QTextHtmlParser::parse() at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtexthtmlparser.cpp:640 #4 0x000000010190d9e1 in QTextHtmlParser::parse(QString const&, QTextDocument const*) at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtexthtmlparser.cpp:583 #5 0x00000001018a5e6c in QTextHtmlImporter::QTextHtmlImporter(QTextDocument*, QString const&, QTextHtmlImporter::ImportMode, QTextDocument const*) at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtextdocumentfragment.cpp:445 #6 0x00000001018a5fa3 in QTextHtmlImporter::QTextHtmlImporter(QTextDocument*, QString const&, QTextHtmlImporter::ImportMode, QTextDocument const*) at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtextdocumentfragment.cpp:423 #7 0x0000000101879576 in QTextDocument::setHtml(QString const&) at /Users/torarne/dev/qt/6.0/qtbase/src/gui/text/qtextdocument.cpp:1257 #8 0x0000000100415287 in QLabelPrivate::ensureTextPopulated() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/widgets/qlabel.cpp:1528 #9 0x0000000100414c1d in QLabelPrivate::ensureTextLayouted() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/widgets/qlabel.cpp:1565 #10 0x00000001004143c7 in QLabelPrivate::sizeForWidth(int) const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/widgets/qlabel.cpp:631 #11 0x000000010041580f in QLabel::minimumSizeHint() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/widgets/qlabel.cpp:878 #12 0x0000000100415724 in QLabel::sizeHint() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/widgets/qlabel.cpp:861 #13 0x0000000100208d7e in QWidgetItemV2::updateCacheIfNecessary() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qlayoutitem.cpp:733 #14 0x00000001002093e0 in QWidgetItemV2::maximumSize() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qlayoutitem.cpp:821 #15 0x00000001001c1172 in QBoxLayoutPrivate::setupGeom() at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qboxlayout.cpp:288 #16 0x00000001001c2e5d in QBoxLayout::minimumSize() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qboxlayout.cpp:626 #17 0x0000000100201ff3 in QLayout::totalMinimumSize() const at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qlayout.cpp:639 #18 0x00000001002019ea in QLayout::activate() at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qlayout.cpp:1040 #19 0x0000000100230c95 in QWidgetPrivate::setVisible(bool) at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qwidget.cpp:8021 #20 0x0000000100230ac2 in QWidget::setVisible(bool) at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qwidget.cpp:7983 #21 0x000000010022fc4b in QWidget::show() at /Users/torarne/dev/qt/6.0/qtbase/src/widgets/kernel/qwidget.cpp:7609 #22 0x0000000100002a54 in main at /Users/torarne/Downloads/palette/main.cpp:64
The color is actually flattened earlier than the backtrace shows, and can be improved by the linked patch, but is still fundamentally broken in that it flattens.
Attachments
Issue Links
- duplicates
-
QTBUG-25117 Qt 5 to-do in QTextHtmlParser
- Closed
Gerrit Reviews
For Gerrit Dashboard: QTBUG-85567 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
307668,2 | Don't flatten link color in QTextHtmlParser::declarationsForNode | dev | qt/qtbase | Status: MERGED | +2 | 0 |