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

selecting whole text with Ctrl+A does not emit cursorPositionChanged() in Q(Plain)TextEdit

XMLWordPrintable

    • fed79b873 (dev), 4c3f57613 (6.5)

      QTextEdit and QPlainText do not correctly emit cursorPositionChanged() signal when user selects the whole text (with Ctrl+A) and probably also when selecting text programatically with selectAll().

      Run the following snippet and press Ctrl+A. The whole text will be selected and the cursor will be moved to the end of the text. But nothing will be written to console despite the fact that it should write that the cursor position was changed to the position at the end of the text. In contrast when selecting the text with Ctrl+Shift+End, the text cursor position change is correctly emitted and reported.

      #include <QApplication>
      #include <QDebug>
      #include <QTextEdit>
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QTextEdit edit;
          edit.setText("asdhasjkd\nasjkdh ajksdhasjk\nasdhasjkhd asd ashdkjash\n");
          edit.show();
          QObject::connect(&edit, &QTextEdit::cursorPositionChanged,
                           [&edit]{ qDebug() << "cursor changed" << edit.textCursor().position(); });
          return a.exec();
      }
      

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

            liaqi Liang Qi
            vladimir.kraus Vladimir Kraus
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes