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

QPlainTextEdit::appendPlainText() lead to very high CPU consumption

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • P3: Somewhat important
    • None
    • 5.5.0, 5.6.0, 5.7.0, 5.8.0, 5.9.0, 5.10.0
    • None
    • * Windows 10 64bit
       * Qt 5.9.2 MSVC 2015 32 bit
       * CPU 15-3470 && 8GB RAM

    Description

      Following code:

      #include <QApplication>
      #include <QPlainTextEdit>
      #include <QTimer>
      
      
      static int counter = 0;
      
      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
          auto textEdit = new QPlainTextEdit;
          textEdit->setMaximumBlockCount(10);
          textEdit->show();
          auto timer = new QTimer;
          QCoreApplication::connect(timer, &QTimer::timeout, [textEdit]() {
              textEdit->appendPlainText(QString::number(++counter));
          });
          timer->start(1);
          return a.exec();
      }
      

      takes very high ~30% for the CPU consumption.

      Seems, something are not optimal in the widget's paint events and so on implementation. Is it normal?

      Attachments

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

        Activity

          People

            richard Richard Moe Gustavsen
            kuzulis Denis Shienkov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes