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

QPlainTextEdit scrolls to cursor on alt-tab on ubuntu

    XMLWordPrintable

    Details

    • Platform/s:
      Linux/X11
    • Commits:
      8b3f2dd994 (qt/qtbase/dev) 8b3f2dd994 (qt/tqtc-qtbase/dev) 567d047c4e (qt/tqtc-qtbase/6.2) 6d41c144ae (qt/qtbase/6.3) 6d41c144ae (qt/tqtc-qtbase/6.3)

      Description

      Steps to reproduce:

      1. Create QPlainTextEdit with enough text data to be able to scroll
      2. Put cursor on first line
      3. Scroll down, so cursor goes out of view
      4. Switch to another application and back

      Expected result:

      Scroll position remains unchanged, cursor is out of view

      Actual result:

      Scroll position changed, it scrolled up to ensure cursor is visible

      Sample code to reproduce the issue:

       

      #include <QApplication>
      #include <QPlainTextEdit>
         
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          QPlainTextEdit e;
          const QString text = "Quidem soluta at dolores autem voluptatem nisi impedit. Et sint eligendi consectetur. Explicabo quos molestias error. Sit saepe tempore sint delectus qui quo. Magni veritatis ut debitis a ipsum."
                               "Officia dolorum iure dicta consequatur. Aut similique nihil ea ut voluptates eos. Qui in asperiores omnis eum tempore. Dolor reprehenderit accusantium ratione necessitatibus perferendis quo voluptatem error."
                               "Quam ratione voluptas qui in et. Qui eveniet id adipisci molestiae et rerum et. Voluptas provident ducimus et earum. Veritatis facilis unde sunt. Id voluptatum ullam aut labore et sapiente iure."
                               "Culpa illum mollitia aliquam ut. Totam eum repellat harum placeat a commodi. Architecto assumenda omnis et. Reiciendis facilis dignissimos omnis consequatur."
                               "A laudantium harum eius suscipit. Veritatis aspernatur dolorem ipsa sit. Nobis repellendus dolorem dolore alias quia. Cupiditate quidem ut ea.";
          e.setPlainText(text);
          e.show();
          return a.exec();
      }
      

      This is a cause of QTCREATORBUG-26628

      Video of a problem:

      https://youtu.be/B4vZKCwblI4

      Video without a problem when filtering empty QInputMethod events. Also, input method demonstrated (ctrl-shift-u, 123, enter):

      https://youtu.be/_w5w6GgsRqE

      I have no environment set to build Qt libraries, but the fix would be to check for empty input method events and don't scroll to cursor.

       

      // qplaintextedit.cpp:2206
      void QPlainTextEdit::inputMethodEvent(QInputMethodEvent *e) 
      {
      ...
          const bool emptyEvent = e->preeditString().isEmpty() 
                                  && e->commitString().isEmpty()
                                  && e->attributes().isEmpty();
          if (!emptyEvent) {
              ensureCursorVisible();
          }
      }

       

       

        Attachments

          Issue Links

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

            Activity

              People

              Assignee:
              qt.team.quick.subscriptions Qt Quick and Widgets Team
              Reporter:
              volodymyr_zibarov Volodymr Zibarov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes