Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPlainTextEdit stops updating

QPlainTextEdit stops updating

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 778 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sucharek
    wrote on last edited by
    #1

    Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
    To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.

    Here's the modification code:

    QString text = ui->plainTextEdit_Log->toPlainText();
    int check = text.count();
    if (check > 10000) {
        qDebug() << "triggered";
        text.remove(0, 6000);
        ui->plainTextEdit_Log->setPlainText(text);
        ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());
         qDebug() << "finished";
    }
    

    Can I fix this somehow?

    JonBJ 2 Replies Last reply
    0
    • S Sucharek

      Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
      To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.

      Here's the modification code:

      QString text = ui->plainTextEdit_Log->toPlainText();
      int check = text.count();
      if (check > 10000) {
          qDebug() << "triggered";
          text.remove(0, 6000);
          ui->plainTextEdit_Log->setPlainText(text);
          ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());
           qDebug() << "finished";
      }
      

      Can I fix this somehow?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #4

      @Sucharek said in QPlainTextEdit stops updating:

      There's a lot of text and updates (1 line/1ms)

      I have not/cannot test this. It seems pretty unreasonably frequent if this is your issue. User cannot see updates so fast. If you cannot resolve, what about buffering these updates to no more than ten times a second or whatever, does that improve? And/or maybe use the QTextCursor to append at the end, setting the complete text edit 4k at a time might be "slow"?

      S 1 Reply Last reply
      2
      • S Sucharek

        Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
        To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.

        Here's the modification code:

        QString text = ui->plainTextEdit_Log->toPlainText();
        int check = text.count();
        if (check > 10000) {
            qDebug() << "triggered";
            text.remove(0, 6000);
            ui->plainTextEdit_Log->setPlainText(text);
            ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());
             qDebug() << "finished";
        }
        

        Can I fix this somehow?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by
        #2

        @Sucharek said in QPlainTextEdit stops updating:

        ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());

        Does it work if you comment this line out?

        S 1 Reply Last reply
        0
        • JonBJ JonB

          @Sucharek said in QPlainTextEdit stops updating:

          ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());

          Does it work if you comment this line out?

          S Offline
          S Offline
          Sucharek
          wrote on last edited by
          #3

          Hi @JonB, no it's still stuck.

          1 Reply Last reply
          0
          • S Sucharek

            Hi, I'm having issues with QPlainText edit. I'm using it to display an output log. There's a lot of text and updates (1 line/1ms). After a lot of text is displayed and more is displaying, the app crashes.
            To fix the crashing, I decided to limit how many characters can be in there at once, 4 thousand. So, I took the text from QPlainTextEdit, removed the characters and set the text. That doesn't work. When the modification gets triggered, QPlainTextEdit freezes and doesn't update, untill you click in it. Also the text updates depending where you clicked, so half of it can just be stuck, while the other half is updating.

            Here's the modification code:

            QString text = ui->plainTextEdit_Log->toPlainText();
            int check = text.count();
            if (check > 10000) {
                qDebug() << "triggered";
                text.remove(0, 6000);
                ui->plainTextEdit_Log->setPlainText(text);
                ui->plainTextEdit_Log->verticalScrollBar()->setValue(ui->plainTextEdit_Log->verticalScrollBar()->maximum());
                 qDebug() << "finished";
            }
            

            Can I fix this somehow?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @Sucharek said in QPlainTextEdit stops updating:

            There's a lot of text and updates (1 line/1ms)

            I have not/cannot test this. It seems pretty unreasonably frequent if this is your issue. User cannot see updates so fast. If you cannot resolve, what about buffering these updates to no more than ten times a second or whatever, does that improve? And/or maybe use the QTextCursor to append at the end, setting the complete text edit 4k at a time might be "slow"?

            S 1 Reply Last reply
            2
            • JonBJ JonB

              @Sucharek said in QPlainTextEdit stops updating:

              There's a lot of text and updates (1 line/1ms)

              I have not/cannot test this. It seems pretty unreasonably frequent if this is your issue. User cannot see updates so fast. If you cannot resolve, what about buffering these updates to no more than ten times a second or whatever, does that improve? And/or maybe use the QTextCursor to append at the end, setting the complete text edit 4k at a time might be "slow"?

              S Offline
              S Offline
              Sucharek
              wrote on last edited by
              #5

              @JonB appending text worked.
              I still left the 1 line/1ms. It's not always like that, just sometimes.
              Thanks.

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved