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

QTextLayout detecting new line in text

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.15.0 RC2
    • GUI: Text handling
    • None

       

      Creating text layout using QTextLayout while providing text (QString) which contains multiple lines and new line symbols of `\n`, `\r` or any combination of them, fails and renders them in one line.

      It appears that QTextLayout works correctly only if line break symbol is provided as `QChar::LineSeparator`, hence each time it's necessary to conduct

       

      text.replace('\n', QChar::LineSeparator);
      

      and that is not not obvious.  Above code-snippet is also present in QTextLayout unit tests

      There is no documentation information  - which I was able to find, what characters are supported for line breaking in QTextLayout context.

      If implementation choice is justified then maybe it would be beneficial to add information into QTextLayout documentation, how to break lines.

       

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

            esabraha Eskil Abrahamsen Blomfeldt
            hubert.liberacki Hubert Liberacki
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes