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

Regression: html copied from QTextEdit loses style



    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: GUI: Text handling
    • Labels:


      After QTBUG-54787 (that was not resolved, but has a commit integrated in the releases), there is a regression of html appearance being changed when copying the text in the clipboard.

      My comment in the initial bug got no response, so i am creating a new bug here.

      If a table or a child <td> has the style "white-space: nowrap=true", now, when copied to clipboard, in QTextHtmlImporter::processBlockNode(), the block format now has NonBreakableLines attribute. Which seems legit as far as i understand.

      But then, in QTextHtmlExporter::emitBlock(), because of that new attribute, the block is put inside of a <pre> instead of a <p> previously. <pre> indeed forbids text wrapping, but it also preformatted text with fixed width, and the formatting of the text that was inside is lost, so the html displayed when pasting this is different from the displayed html that was copied.

      I think the condition in emitBlock()

      const bool pre = blockFormat.nonBreakableLines();

      is wrong, because indeed, pre has nowrap style the text in the <pre> actually is broken into multiple lines if the window is not wide. And nowrap style does not imply that we want <pre> formating. In my opinion, when nonBreakableLines() returns true, it would be more fitted to keep a <p> but with white-space: nowrap style




          Issue Links

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



              esabraha Eskil Abrahamsen Blomfeldt
              bartoli Olivier BARTHELEMY
              0 Vote for this issue
              2 Start watching this issue



                  Gerrit Reviews

                  There are no open Gerrit changes