How to add big size text to a TextEdit, without CPU rapid rising.
-
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.
-
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 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. -
Have you tried setText() method ??
like:
QString tt = "Any Text" ;
ui->textEdit->setText(tr("hello %1").arg(tt)); -
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] -
Memory leak would be the reason for such higher CPU utilisation . Please keep this thing into consideration.
-
Yes,I did think about.But the memory is small.less than 100MB.but CPU is more than 50%.
-
Excuse me, I met the same question with you, is there any methods found to solve this question?
-
@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).