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. How to add big size text to a TextEdit, without CPU rapid rising.

How to add big size text to a TextEdit, without CPU rapid rising.

Scheduled Pinned Locked Moved General and Desktop
13 Posts 4 Posters 2.4k Views
  • 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.
  • L Offline
    L Offline
    lampard2013
    wrote on 9 Jun 2014, 05:42 last edited by
    #3

    [quote author="ankursaxena" date="1402289181"]Welcome to devnet qt,

    May be this help u. Read out it.

    http://qt-project.org/doc/qt-4.8/richtext-advanced-processing.html[/quote]
    I read the page,the example code uses "insertblock()"function which will start a new line.But I do not want this result.

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lampard2013
      wrote on 9 Jun 2014, 06:08 last edited by
      #4

      Is there a method make QTextEdit add text but do not start a new line,and even through the text size is very large,app can still run fast.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ankursaxena
        wrote on 9 Jun 2014, 06:10 last edited by
        #5

        I have read about insertblock(). and I found something which may be important for you.

        "Text strings can be inserted into the document with the insertText() function, blocks (representing new paragraphs) can be inserted with insertBlock()."

        "Existing fragments of text can be inserted with insertFragment() but, if you want to insert pieces of text in various formats, it is usually still easier to use insertText() and supply a character format."

        So, may be u should not use insertBlock(). in spite of this, u should use insertText(). I don't know in what consideration u r using this. So i can't tell you what is the exact solution.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ankursaxena
          wrote on 9 Jun 2014, 06:12 last edited by
          #6

          References :

          http://qt-project.org/doc/qt-4.8/qtextcursor.html#details

          http://qt-project.org/doc/qt-4.8/richtext-cursor.html#inserting-document-elements

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lampard2013
            wrote on 9 Jun 2014, 06:27 last edited by
            #7

            [quote author="ankursaxena" date="1402294218"]I have read about insertblock(). and I found something which may be important for you.

            "Text strings can be inserted into the document with the insertText() function, blocks (representing new paragraphs) can be inserted with insertBlock()."

            "Existing fragments of text can be inserted with insertFragment() but, if you want to insert pieces of text in various formats, it is usually still easier to use insertText() and supply a character format."

            So, may be u should not use insertBlock(). in spite of this, u should use insertText(). I don't know in what consideration u r using this. So i can't tell you what is the exact solution.

            [/quote]
            I use it into a com port data reading app.I use a Qthread read the data continually.And when I read new data I put it into TextEdit.
            I want the data displayed without newline.So I used insertText() first.But when App run a period of time, the CPU is high.So I use append() instead.but append have newline.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              ankursaxena
              wrote on 9 Jun 2014, 06:49 last edited by
              #8

              Have you tried setText() method ??

              like:

              QString tt = "Any Text" ;
              ui->textEdit->setText(tr("hello %1").arg(tt));

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lampard2013
                wrote on 9 Jun 2014, 07:22 last edited by
                #9

                I tried this method ,but the CPU was very high.
                [quote author="ankursaxena" date="1402296578"]Have you tried setText() method ??

                like:

                QString tt = "Any Text" ;
                ui->textEdit->setText(tr("hello %1").arg(tt));
                [/quote]

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  ankursaxena
                  wrote on 9 Jun 2014, 07:27 last edited by
                  #10

                  Memory leak would be the reason for such higher CPU utilisation . Please keep this thing into consideration.

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lampard2013
                    wrote on 9 Jun 2014, 07:54 last edited by
                    #11

                    Yes,I did think about.But the memory is small.less than 100MB.but CPU is more than 50%.

                    1 Reply Last reply
                    0
                    • L Offline
                      L Offline
                      lion zhang
                      wrote on 23 Mar 2025, 08:35 last edited by
                      #12

                      Excuse me, I met the same question with you, is there any methods found to solve this question?

                      I 1 Reply Last reply 23 Mar 2025, 19:40
                      0
                      • L lion zhang
                        23 Mar 2025, 08:35

                        Excuse me, I met the same question with you, is there any methods found to solve this question?

                        I Offline
                        I Offline
                        IgKh
                        wrote on 23 Mar 2025, 19:40 last edited by
                        #13

                        @lion-zhang Welcome to the forum. Instead of reviving a very old topic with no clear problem statement relating to a long deprecated version of Qt , it would be more effective if you start your own topic. Make sure to specify which version of Qt you are using, on what operating system, what exactly are you doing (ideally with some sample code) and what is the performance issue you are experiencing (CPU, memory leaking, etc).

                        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