Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.11.2, 5.12.0, 5.13.0 Alpha 1
-
None
Description
Hi all,
QTextEdit (and QTextBrowser) keeps styled text parts with a selection while changing its content.
Here is a small example:
/*QTextBrowser*/ QTextEdit t_browser; t_browser.setReadOnly(true); t_browser.setHtml(R"(<p style="color: red; font-weight: bold;">________________test123</p>)"); QPushButton p_button("CLICK ME!", &t_browser); QObject::connect(&p_button, &QPushButton::clicked, [&]() { t_browser.setPlainText("________________test456"); }); t_browser.show();
If you click the button without a selection, the content is changed and no style will be taken.
If you select something within the text or the text fragment itself and press the button afterwards, the new plain text will be styled like the previous text.