Discussion:
[Interest] QTextEdit is too slow - hints needed
JM
2013-01-15 00:16:09 UTC
Permalink
Hi all,

I am using QTextEdit to display log text files, just like the Unix command tail -f.
My current implementation just displays the last 5 lines and then follows the growing
log file, displaying lines as they come.
Now, I am asked to make QTextEdit display the whole file when the user opens a file.
A log file can be very large. I tested it with a 2mbyte file, and inserting data to QTextEdit
caused the GUI to freeze for almost 1 minute.
This is not acceptable, and I am looking for a solution. I have the following questions:

-) what is the fastest way to insert lots of text into QTextEdit?
-) should I go to the route of implementing my own QTextDisplay? If so,
should I use QAbstractScrollArea as class base? Any pointer to how to use it?

Thanks in advance,
JM
1+1=2
2013-01-15 00:19:06 UTC
Permalink
Hi,

You should use QPlainTextEdit instead of QTextEdit.

Regards.
Post by JM
Hi all,
I am using QTextEdit to display log text files, just like the Unix command tail -f.
My current implementation just displays the last 5 lines and then follows the growing
log file, displaying lines as they come.
Now, I am asked to make QTextEdit display the whole file when the user opens a file.
A log file can be very large. I tested it with a 2mbyte file, and
inserting data to QTextEdit
caused the GUI to freeze for almost 1 minute.
-) what is the fastest way to insert lots of text into QTextEdit?
-) should I go to the route of implementing my own QTextDisplay? If so,
should I use QAbstractScrollArea as class base? Any pointer to how to use it?
Thanks in advance,
JM
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
William Hallatt
2013-01-15 05:43:16 UTC
Permalink
I've battled with the same issue. I still haven't got a final solution, but
the following did help me speed things up a bit (using QPlainTextEdit),:

m_yourPlainTextEdit->setUpdatesEnabled( false ); // disables receipt of
paint events
m_yourPlainTextEdit->setPlainText( lotsOfText );
m_yourPlainTextEdit->setUpdatesEnabled( false ); // enables receipt of
paint events

(you can obviously refer to the API documentation for further details re
"setUpdatesEnabled").

Hope that helps!

Regards,
William Hallatt
Post by 1+1=2
Hi,
You should use QPlainTextEdit instead of QTextEdit.
Regards.
Post by JM
Hi all,
I am using QTextEdit to display log text files, just like the Unix command tail -f.
My current implementation just displays the last 5 lines and then follows the growing
log file, displaying lines as they come.
Now, I am asked to make QTextEdit display the whole file when the user opens a file.
A log file can be very large. I tested it with a 2mbyte file, and
inserting data to QTextEdit
caused the GUI to freeze for almost 1 minute.
-) what is the fastest way to insert lots of text into QTextEdit?
-) should I go to the route of implementing my own QTextDisplay? If so,
should I use QAbstractScrollArea as class base? Any pointer to how to use it?
Thanks in advance,
JM
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Jason H
2013-01-15 23:24:49 UTC
Permalink
Use PlainTextEdit or develop your own Widget.
If I rememer correctly, a significant amount of time was consumed in formatting the text. Since you're appending, you shouldn't need to layout (wrap) anything but the current line. So when you append text you don't re-avaliate the block of text. In a weird way a combolist box might be what you want.






________________________________
From: JM <***@email.it>
To: ***@qt-project.org
Sent: Monday, January 14, 2013 7:16 PM
Subject: [Interest] QTextEdit is too slow - hints needed

Hi all,

I am using QTextEdit to display log text files, just like the Unix command tail -f.
My current implementation just displays the last 5 lines and then follows the growing
log file, displaying lines as they come.
Now, I am asked to make QTextEdit display the whole file when the user opens a file.
A log file can be very large. I tested it with a 2mbyte file, and inserting data to QTextEdit
caused the GUI to freeze for almost 1 minute.
This is not acceptable, and I am looking for a solution. I have the following questions:

-) what is the fastest way to insert lots of text into QTextEdit?
-) should I go to the route of implementing my own QTextDisplay? If so,
should I use QAbstractScrollArea as class base? Any pointer to how to use it?

Thanks in advance,
JM
M. Bashir Al-Noimi
2013-01-16 08:47:15 UTC
Permalink
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bidimailui-detected-decoding-type="UTF-8" bgcolor="#FFFFFF"
text="#000000">
<div class="moz-cite-prefix">On 15/01/2013 01:16 ص, JM wrote:<br>
</div>
<blockquote cite="mid:***@xenon15" type="cite">
<pre wrap="">Hi all,

I am using QTextEdit to display log text files, just like the Unix command tail -f.
My current implementation just displays the last 5 lines and then follows the growing
log file, displaying lines as they come.
Now, I am asked to make QTextEdit display the whole file when the user opens a file.
A log file can be very large. I tested it with a 2mbyte file, and inserting data to QTextEdit
caused the GUI to freeze for almost 1 minute.
This is not acceptable, and I am looking for a solution. I have the following questions:

-) what is the fastest way to insert lots of text into QTextEdit?
-) should I go to the route of implementing my own QTextDisplay? If so,
should I use QAbstractScrollArea as class base? Any pointer to how to use it?

Thanks in advance,
JM
_______________________________________________
Interest mailing list
<a class="moz-txt-link-abbreviated" href="mailto:***@qt-project.org">***@qt-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/interest">http://lists.qt-project.org/mailman/listinfo/interest</a>

</pre>
</blockquote>
Personally I didn't face this issue before, but I suggest to use
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
QTextBrowser because it optimized for text displaying or you can use
QListWidget instead (I prefer it) thus it's easy to add tons of
items as you want.<br>
<br>
<pre class="moz-signature" cols="72">--
Best Regards
Muhammad Bashir Al-Noimi</pre>
</body>
</html>
M. Bashir Al-Noimi
2013-01-16 09:15:42 UTC
Permalink
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bidimailui-detected-decoding-type="UTF-8" bgcolor="#FFFFFF"
text="#000000">
<div class="moz-cite-prefix">On 16/01/2013 09:47 ص, M. Bashir
Al-Noimi wrote:<br>
</div>
<blockquote cite="mid:***@gmail.com" type="cite">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<div class="moz-cite-prefix">On 15/01/2013 01:16 ص, JM wrote:<br>
</div>
<blockquote cite="mid:***@xenon15" type="cite">
<pre wrap="">Hi all,

I am using QTextEdit to display log text files, just like the Unix command tail -f.
My current implementation just displays the last 5 lines and then follows the growing
log file, displaying lines as they come.
Now, I am asked to make QTextEdit display the whole file when the user opens a file.
A log file can be very large. I tested it with a 2mbyte file, and inserting data to QTextEdit
caused the GUI to freeze for almost 1 minute.
This is not acceptable, and I am looking for a solution. I have the following questions:

-) what is the fastest way to insert lots of text into QTextEdit?
-) should I go to the route of implementing my own QTextDisplay? If so,
should I use QAbstractScrollArea as class base? Any pointer to how to use it?

Thanks in advance,
JM
_______________________________________________
Interest mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:***@qt-project.org">***@qt-project.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.qt-project.org/mailman/listinfo/interest">http://lists.qt-project.org/mailman/listinfo/interest</a>

</pre>
</blockquote>
Personally I didn't face this issue before, but I suggest to use
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
QTextBrowser because it optimized for text displaying or you can
use QListWidget instead (I prefer it) thus it's easy to add tons
of items as you want.<br>
<br>
<pre class="moz-signature" cols="72">--
Best Regards
Muhammad Bashir Al-Noimi</pre>
</blockquote>
<font face="Tahoma">I googled to see if there is an issue about it
but I found this library which could be interesting for fixing
logging issue:<br>
<a class="moz-txt-link-freetext" href="http://www.qtilities.org/docs/v1_1/page_logging.html">http://www.qtilities.org/docs/v1_1/page_logging.html</a><br>
</font><br>
<pre class="moz-signature" cols="72">--
Best Regards
Muhammad Bashir Al-Noimi</pre>
</body>
</html>
William Hallatt
2013-01-16 11:25:19 UTC
Permalink
Hi Muhammad

QTextBrowser inherits QTextEdit so I doubt it will be any better :)
Post by M. Bashir Al-Noimi
Personally I didn't face this issue before, but I suggest to use
QTextBrowser because it optimized for text displaying or you can use
QListWidget instead (I prefer it) thus it's easy to add tons of items as
you want.
--
Best Regards
Muhammad Bashir Al-Noimi
_______________________________________________
Interest mailing list
http://lists.qt-project.org/mailman/listinfo/interest
Loading...