Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-74098

QTextEdit keeps styled text parts with a selection while changing its content

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11.2, 5.12.0, 5.13.0 Alpha 1
    • GUI: Text handling
    • None
    • Windows

    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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            lachrymology Mike
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes