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

QTextFormat::FullWidthSelection stops at end of last character in line

    XMLWordPrintable

Details

    Description

      The selection should cover the whole line in the editor (like in Qt 4.3), but instead it stops at the last character of the line.

      Test case main.cpp to reproduce:
      //---------------------------------------
      #include <QtGui>

      class Text: public QTextEdit
      {
      public:
      Text(QWidget* pParent = 0);
      void paintEvent(QPaintEvent *event);
      };

      Text::Text(QWidget* pParent) : QTextEdit(pParent)
      {
      this->setLineWrapMode(NoWrap);
      this->setPlainText("Hello World\nOla' Mundo");
      }

      void Text::paintEvent(QPaintEvent *event)
      {
      QTextEdit::ExtraSelection highlight;
      QList<QTextEdit::ExtraSelection> extras;
      QList<QTextCursor*> errorCursors;
      QTextCursor originalCursor = this->textCursor();
      QTextCursor cursor = this->textCursor();

      // Mark current line
      highlight.cursor = this->textCursor();
      highlight.format.setProperty(QTextFormat::FullWidthSelection, true);
      highlight.format.setBackground(QColor(0,255,0));
      extras << highlight;

      // Add extra selections
      this->setExtraSelections(extras);

      QTextEdit::paintEvent(event);
      }

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);
      Text widget;
      widget.show();
      return app.exec();
      }
      //---------------------------------------

      Attachments

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

        Activity

          People

            sletta Gunnar Sletta
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes