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. Problem with QPlainTextEdit
Forum Updated to NodeBB v4.3 + New Features

Problem with QPlainTextEdit

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 495 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.
  • G Offline
    G Offline
    GGG03
    wrote on last edited by
    #1

    I need to show data like a terminal in QT (Like Arduino with a Serial port). I'm using a QPlainTextEdit because it is the only option I've found. But it adds so much latency and makes the app laggy.

    fb255082-6e3a-49d1-929f-15d10dff4070-image.png
    Here is with QTextEdit.
    92ad7e37-f68a-40bb-98e3-274057615b9f-image.png
    Here without it.
    Is there anyway to make it not laggy or to show data like arduino's serial monitor?

    C 1 Reply Last reply
    0
    • G Offline
      G Offline
      GGG03
      wrote on last edited by
      #7

      I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.

      C JonBJ 2 Replies Last reply
      0
      • G GGG03

        I need to show data like a terminal in QT (Like Arduino with a Serial port). I'm using a QPlainTextEdit because it is the only option I've found. But it adds so much latency and makes the app laggy.

        fb255082-6e3a-49d1-929f-15d10dff4070-image.png
        Here is with QTextEdit.
        92ad7e37-f68a-40bb-98e3-274057615b9f-image.png
        Here without it.
        Is there anyway to make it not laggy or to show data like arduino's serial monitor?

        C Offline
        C Offline
        CPPUIX
        wrote on last edited by
        #2

        @GGG03 Would this be of any help?

        Or any of these?

        If not and you still want to continue using QPlainTextEdit, then you need to show how you are using it, maybe someone can optimize your code and improve its performance.

        G 1 Reply Last reply
        0
        • C CPPUIX

          @GGG03 Would this be of any help?

          Or any of these?

          If not and you still want to continue using QPlainTextEdit, then you need to show how you are using it, maybe someone can optimize your code and improve its performance.

          G Offline
          G Offline
          GGG03
          wrote on last edited by
          #3

          This is the code of the QTextEdit

              cursor.movePosition(QTextCursor::Start);
              cursor.insertText(show);
              nLines += 2;
          
              if (nLines < -100)
              {
                  nLines -= 2;
                  cursor.movePosition(QTextCursor::Start);
                  cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, nLines-1);
                  cursor.select(QTextCursor::LineUnderCursor);
                  cursor.removeSelectedText();
                  cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, 1);
                  cursor.select(QTextCursor::LineUnderCursor);
                  cursor.removeSelectedText();
                  cursor.deleteChar();
              }
          
          JonBJ 1 Reply Last reply
          0
          • G GGG03

            This is the code of the QTextEdit

                cursor.movePosition(QTextCursor::Start);
                cursor.insertText(show);
                nLines += 2;
            
                if (nLines < -100)
                {
                    nLines -= 2;
                    cursor.movePosition(QTextCursor::Start);
                    cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, nLines-1);
                    cursor.select(QTextCursor::LineUnderCursor);
                    cursor.removeSelectedText();
                    cursor.movePosition(QTextCursor::Down, QTextCursor::MoveAnchor, 1);
                    cursor.select(QTextCursor::LineUnderCursor);
                    cursor.removeSelectedText();
                    cursor.deleteChar();
                }
            
            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #4

            @GGG03
            That is quite a bit of moving the cursor around, selecting, scrolling etc. It might be the case that reading the whole text from the text edit (or keeping it in memory), deleting the first line in memory from it, appending the new stuff and doing a complete setText() could be faster, you'd have to try. Or, I can't figure how often you are updating, you might want to "buffer" a few updates at a time. For example, user cannot read text updated e.g. every 1ms so no need to.

            G 2 Replies Last reply
            0
            • JonBJ JonB

              @GGG03
              That is quite a bit of moving the cursor around, selecting, scrolling etc. It might be the case that reading the whole text from the text edit (or keeping it in memory), deleting the first line in memory from it, appending the new stuff and doing a complete setText() could be faster, you'd have to try. Or, I can't figure how often you are updating, you might want to "buffer" a few updates at a time. For example, user cannot read text updated e.g. every 1ms so no need to.

              G Offline
              G Offline
              GGG03
              wrote on last edited by
              #5

              @JonB I'm gonna test it with setText. Just so you know, I have the same problem deactivating the erase part, so I don't think is the cursor.

              1 Reply Last reply
              0
              • JonBJ JonB

                @GGG03
                That is quite a bit of moving the cursor around, selecting, scrolling etc. It might be the case that reading the whole text from the text edit (or keeping it in memory), deleting the first line in memory from it, appending the new stuff and doing a complete setText() could be faster, you'd have to try. Or, I can't figure how often you are updating, you might want to "buffer" a few updates at a time. For example, user cannot read text updated e.g. every 1ms so no need to.

                G Offline
                G Offline
                GGG03
                wrote on last edited by
                #6

                @JonB Nothing, it works even worse.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  GGG03
                  wrote on last edited by
                  #7

                  I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.

                  C JonBJ 2 Replies Last reply
                  0
                  • G GGG03

                    I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.

                    C Offline
                    C Offline
                    CPPUIX
                    wrote on last edited by
                    #8

                    @GGG03 don't forget to mark this topic as solved if your problem's solved.

                    1 Reply Last reply
                    0
                    • G GGG03 has marked this topic as solved on
                    • G GGG03

                      I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.

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

                      @GGG03 said in Problem with QPlainTextEdit:

                      I found the problem. It was the font. I was using Terminal 9, and with Segou UI it is not laggy.

                      LOL! Hopeless.

                      1 Reply Last reply
                      0

                      • Login

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