Requirement: Ability to control the total number of rows displayed. But do not want too heavy, simple display just fine.
Reference StackOverflow
Using Qplaintextedit
If you want to limit the total number of paragraphs in a qplaintextedit, as it was for example useful in a log viewer and then You can use the Maximumblockcount property. The combination of and turns into a setMaximumBlockCount()
appendPlainText()
QPlainTextEdit
efficient Viewer for log text. The scrolling can reduced centerOnScroll()
with the property, making the log viewer even faster. Text can is formatted in a limited, either using a syntax highlighter (see below), or by appending html-formatted text With appendHtml()
. QPlainTextEdit
while does isn't support complex rich-text rendering with tables and floats, it does support limited paragraph-based f Ormatting. Need in a log viewer.
Combining the Setmaximumblockcount () and Appendplaintext () methods to implement the display of logger, you can control the total number of rows displayed.
- It's a little more lightweight.
- The disadvantage is that there is no good way to highlight error,warning and so on.
- Disadvantages, making screening relatively troublesome
Use Qlistwidget or Qtablewidget
You can set the total number of rows to control the number of logs displayed.
- Disadvantages, relative to the post-emphasis
- Advantages, can be conveniently used in different colors highlighting error,warning and so on.
Fast implementation
can refer to the QT log output file, relatively easy to achieve points.
QT implementation of Logger log display