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

Selected text discrepancy

    XMLWordPrintable

Details

    • 24cdab32de2abd8669f281dd54c8da1124514915

    Description

      There is a difference between the way QTextEdit and QLineEdit displays selected text. QTextEdit will use the Active color group only if the window is active and the edit has focus. Otherwise it will use Inactive/Disabled depending on the enabled property.

      QLineEdit will use the Active color group if the window is active.

      #include <QApplication>
      #include <QPalette>
      #include <QWidget>
      #include <QVBoxLayout>
      #include <QTextEdit>
      #include <QTextCursor>
      #include <QLineEdit>
      int main(int argc, char **argv)
      {
      QApplication a(argc, argv);
      QPalette p = a.palette();
      p.setBrush(QPalette::Active, QPalette::Highlight, Qt::green);
      p.setBrush(QPalette::Inactive, QPalette::Highlight, Qt::red);
      p.setBrush(QPalette::Disabled, QPalette::Highlight, Qt::blue);
      a.setPalette(p);

      QWidget w;
      QVBoxLayout *l = new QVBoxLayout(&w);
      for (int i=0; i<4; ++i)

      { QTextEdit *edit = new QTextEdit(&w); edit->setHtml("This is a QTextEdit"); QTextCursor cursor = edit->textCursor(); cursor.movePosition(QTextCursor::Start); cursor.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, i); cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2); edit->setTextCursor(cursor); l->addWidget(edit); QLineEdit *e = new QLineEdit("This is a QLineEdit", &w); e->setEnabled(i != 2); e->setSelection(i, 2); l->addWidget(e); }

      w.show();
      return a.exec();
      }

      Attachments

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

        Activity

          People

            ntg Pierre Rossi
            rve Anders Bakken
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes