Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I use
insertPlainText()
to insert data to QTextBrowser in the slot function, but It seems result in lag even no response along with data increasement. But when I add
'\n'
at the end of data to simulate the
append()
, the lag phenomenon disappeared. But I don't want to add a new line, how to solve this problem?
I tried to use
qApp->processEvents()
after the
insertPlainText()
, but it cause crash.
I tried to start a timer to run
qApp->processEvents()
to refresh the UI, but it didn't solve the problem.
Should I start a new thread to receive serial port data? But the inserted data(I mean received data) size is not big, but the total data size in the browser is big. Receive data may not cost a lot of time.
insertPlainText()
performed not well in my machine(i7,16G). It will take about 100ms to insert data when the total data length is about 4096 bytes. I tried the
QScintilla
open source widget which is better but still not perfect. So I think maybe it's wrong thoughts to use
insertPlainText()
.
I changed my thoughts. I use
QByteArray
to store all data and use
setText()
to display the recent 4096 bytes. It looks like I divide the data into many pages and display the recent page. This method solved the problem of how to store the much data. But there is another little problem is that 4096 bytes data can not fill up my screen when I maximize my application. It's not looking good but more data will result in slow response because the app has high data refresh frequency.
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.