Qt5 text Editing

Source: Internet
Author: User

"Application Scenario": Enter a paragraph of text in the edit box, select text with the mouse, modify the font on the toolbar, font size, bold, italic, and other attributes, the selected text changes accordingly.

First,Any text editor program will use Qtextedit as the input text container, in which the editable text entered by Qtextdocument as a carrier, and Qtextblock, Qtextlist, Qtextframe and so on are used to denote elements of qtextdocument, and can also be interpreted as qtextdocument different forms of expression, possibly as strings, paragraphs, lists, tables, or pictures. Each element has its own format, which is described and implemented using classes such as Qtextcharformat, Qtextblockformat, Qtextlistformat, Qtextframeformat, and so on. For example, the Qtextblockformat class corresponds to the Qtextblock class, and the Qtextblock class is used to represent a piece of text, which can generally be understood as a paragraph, but not just a paragraph, and the Qtextblockformat class is used to represent the format of the piece of text, such as an indent value , and four sides of the margin. The division and relationship between the various types can be described:

Second,The Qtextcursor class is a very important and often used class, which is used to represent the cursor in the editing text. This class provides a modification interface to the Qtextdocument document, and all changes to the document format, in the final analysis, are related to the cursor, such as changing the format of the character, which refers to changing the format of the character at the cursor, changing the format of the paragraph, which means changing the format of the paragraph in which the cursor is located, so The Qtextcursor class plays an important role in the document editing class program, and all modifications to Qtextdocument can be implemented through the Qtextcursor class.

" Inheritance Relationship ":

 

Third,Qtextlistformat is mainly used to describe the format of text sorting, it mainly includes two basic properties, a flavor qtextlistformat::style, which means the text is sorted by which sort, and the other is qtextlistformat::indent, Represents the indented value after sorting. Therefore, to achieve the function of text sorting only need to set the Qtextlistformat of these two properties, and the entire format through the Qtextcursor class to apply to the text.

"References":

    1. "Instance" QT Text editor (i) http://blog.chinaunix.net/uid-25806493-id-3346294.html
    2. "Qt 5 Development and examples" (Lu Wenzhou), Fifth: Qt5 main form

Qt5 text Editing

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.