QT implementation of Logger log display

Source: Internet
Author: User

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() . QPlainTextEditwhile 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.