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

Wrap text in tags like pre when explicit width is set

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.13.2
    • None
    • This seems to affect every platform, i.e. Windows, Linux and even SailfishOS, although that probably doesn't count as an official platform.

    • All

    Description

      When you have rich text in a Text element (and variations), text inside a tag like <pre> isn't wrapped. While this is can be considered expected behavior, since a <pre> tag contains pre-formatted text, this often leads to text leaving the bounds of Text element, often even leaving the window. I would expect there to be some kind of switch in Text-like components to wrap every text to be contained inside of it. This only seems to be an issue with Text.RichText, StyledText seems to actually wrap. Since I need to render text from external sources, like Reddit or other sites that format their comments as html, I need to currently replace every <pre> tag with <pre style="white-space: pre-wrap>, which is error prone and because I need some features not available in StyledText, I need to use RichText.

      Example code:

      import QtQuick 2.2
      
      Text {
       width: 200
       wrapMode: Text.Wrap
       textFormat: Text.RichText
       text: "<pre>This is a very long text in a pre tag</pre>"
      }
      

       

      Could something be added to force the text content to respect the width specified or is that maybe even a bug in the rich text support?

      Alternatively, is there a way to optionally add horizontal scrollbars, when a pre text makes the actual text wider than the specified width?

      Thank you,
      Nico

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            deepbluev7 Nicolas Werner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes