QTextBrowser and <hr color=
-
Given:
QColor windowTextColour = palette.color(QPalette::WindowText);
I tried:
textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
Which comes out to <hr color="#ffffff"> if a dark theme is active.
but the hr displayed was dark, not white as requested.
Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?
Thanks
David -
Given:
QColor windowTextColour = palette.color(QPalette::WindowText);
I tried:
textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
Which comes out to <hr color="#ffffff"> if a dark theme is active.
but the hr displayed was dark, not white as requested.
Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?
Thanks
David@Perdrix
color
attribute corresponds to the text color of the content of given element.<hr>
is not a textual element, nor does it have content. You can style the look of it via stylesheet:tb->insertHtml("<hr style=\"background-color:" + windowTextColor.name() + "\">");
or simply:
tb->insertHtml("<hr style=\"background-color: palette(windowText)\">");
-
Given:
QColor windowTextColour = palette.color(QPalette::WindowText);
I tried:
textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
Which comes out to <hr color="#ffffff"> if a dark theme is active.
but the hr displayed was dark, not white as requested.
Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?
Thanks
Davidhr
Horizontal line Supports thewidth
attribute, which can be specified as an absolute or relative (%) value.You can keep asking about each individual tag, but I doubt anyone knows any better than what is listed in "Supported Tags". You can also try
<hr color="red"/>
in a standalone document with no palette/dark mode and verify that does not work.In the case of
hr
tag what evidence do you have that HTML respects color on it anyway? See e.g. https://stackoverflow.com/questions/6979848/horizontal-line-in-qtextedit for this and what you might do (e.g.div
?). -
Given:
QColor windowTextColour = palette.color(QPalette::WindowText);
I tried:
textBrowser.insertHtml(QString("<hr color=\"") + windowTextColour.name() + "\">");
Which comes out to <hr color="#ffffff"> if a dark theme is active.
but the hr displayed was dark, not white as requested.
Did I get the incantation wrong or does the text browser not support specifying color= in an <hr> tag?
Thanks
David@Perdrix
color
attribute corresponds to the text color of the content of given element.<hr>
is not a textual element, nor does it have content. You can style the look of it via stylesheet:tb->insertHtml("<hr style=\"background-color:" + windowTextColor.name() + "\">");
or simply:
tb->insertHtml("<hr style=\"background-color: palette(windowText)\">");
-
P Perdrix has marked this topic as solved on
-
@Perdrix
color
attribute corresponds to the text color of the content of given element.<hr>
is not a textual element, nor does it have content. You can style the look of it via stylesheet:tb->insertHtml("<hr style=\"background-color:" + windowTextColor.name() + "\">");
or simply:
tb->insertHtml("<hr style=\"background-color: palette(windowText)\">");
@Chris-Kawa Kudos!