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

QTextEdit selection highlighting faulty when QTextEdit::NoWrap is set

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.2.0
    • GUI: Text handling
    • None
    • macOS Big Sur 11.6
      QtCreator
    • macOS

    Description

      MacOs: In a simple text editor window, a multi-line text selection is highlighted (light blue background) all the way to the right-hand edge of the editor widget. By default, text wraps at the right-hand edge too. This standard behaviour can be seen in the "SDI Example" application. This reflects the default line wrap mode setting  QTextEdit::WidgetWidth

      When the QTextEdit line wrap is changed to FixedColumnWidth, text selection behaves as expected. But if line wrap is set to either NoWrap or FixedPixelWidth non-standard, problematic text selection can be seen. 

       

      ------------ NoWrap bug -------------

      To demonstrate this bug, in the SDI Example in the function void MainWindow::init(), set line wrap to NoWrap...

      textEdit = new QTextEdit;

      textEdit->setLineWrapMode(QTextEdit::NoWrap); 

      Launch the app, enter text, then Select All. Text selection extends all the way to the right (as expected). But click anywhere to de-select and only some of the blue selection region is reset to white (see screen shot #1). The residual blue region is an ugly and unacceptable artifact.

      Another problem can be seen by triple-clicking a short line. Now the text selection region only extends to the end of the text region, not all the way to the right of the widget. Resize the window, and the selected region jumps all the way to the right - but the extra right-hand selection region can't be deselected (same as following Select All). 

       

      ------------ FixedPixelWidth aesthetic issue -----------

      This problem is less serious. Basically a failure to conform to the MacOS standard. To demonstrate this problem, in the SDI Example set line wrap to FixedPixelWidth and width to 400...

      textEdit->setLineWrapMode(QTextEdit::FixedPixelWidth);

      textEdit->setLineWrapColumnOrWidth( 400 ); 

      Launch the app, enter text, then Select All. Text selection region DOES NOT extends all the way to the right. Instead it is limited to the line wrap width. Deselecting the text works fine, and doesn't leave behind ugly artifacts. 

      ------------ FixedColumnWidth : there is no issue -----------

      Text selection / deselection works as expected for FixedColumnWidth (and WidgetWidth). Ideally the behavior of the other two line wrap modes should conform . 

      ------------------------

      Two screenshots are attached

      1) shows the NoWrap case after Select All, then click anywhere to de-select (ugly selection artifact in right-hand half of widget)

      2) shows the FixedPixelWidth case after Select All (selection region doesn't fully extend to right of widget)

       

      Attachments

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

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            johnc3 John Clements
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes