restlinked.blogg.se

Qt plain text editor
Qt plain text editor












Sometimes it is not possible to accurately build the entire document at one time, it needs to be inserted in the middle, so you need the setPosition command, and the specific value of the positon can be obtained by the above various data types of each block or frame or other types of positon at the beginning, You can also get the length of the current block through length to locate the end position. The above does not set the text format, you can directly assign a text format QTextCharFormat in the second parameter of insertText QTextCursor cursor operation / traverse nested frame / traverse all blocksįirst, he has various instert functions that can be inserted into the data types in the various documents mentioned above. For more layout methods, please refer to: Order Form Example

Qt plain text editor code#

The above code only displays four lines of text, the first two lines are displayed in the root and frame, and the last two lines are displayed in a new frame, and the frame is placed on the right to limit the width. QTextCursor cursor = ui->textEdit->textCursor() QTextLength :: PercentageLength, 40)) // Width setting

qt plain text editor

QTextFrameFormat :: BorderStyle_Solid) // Set the border styleįrame_tPosition (QTextFrameFormat :: FloatRight) // right Root_frame-> setFrameFormat (root_frame_format) // Use the format for the frameįrame_tBackground (Qt :: darkRed) // Set the background colorįrame_tMargin (10) // Set the marginįrame_tPadding (5) // Set paddingįrame_tBorder (2) // Set the border width Root_frame_tBorder (5) // Set the border width Root_frame_tBorderBrush (Qt :: darkBlue) // Set the border color QTextFrameFormat root_frame_format = root_frame-> frameFormat () // Create frame format

qt plain text editor

QTextFrame *root_frame = doc->rootFrame() QTextDocument* doc = ui->textEdit->document() MainWindow::MainWindow(QWidget *parent) : Test source GitHub : QtWidgetsExamples #include "mainwindow.h" Setting the border thickness and color of the root node is similar to setting the border shading of a word document. You need to use QTextDocument :: rootFlrame to get it. QTextDocument is just a document with a root node in it. Order Form ExampleGenerate reports based on some parameter settings, in fact the same principle as above Basic useįirst of all, when you have an edit, you do n’t need to create a document yourself, you can directly use the document method to get the current edited document Text Edit ExampleSimilar to the word editor exampleĬalendar ExampleUse the rich text editor to implement the calendar (it is not recommended to learn this after all, there are already existing calendar controls, and the document is often not inserted into the calendar) Syntax Highlighter ExampleSyntax highlighting examples The official example:Īpplication ExampleThis is relatively simple View the APIs of the two classes, both provide the document method, which can return the QTextDocument pointer, which is used to manipulate the content format of the document through QTextDocument. Note the relationship: QTextDocument> QTextFrame> QTextBlock / QTextTable / QTextList before and after inclusion

qt plain text editor

QTextEdit and QPlainTextEdit options: the difference is that QTextEdit provides tohtml, if you want to process the document, generate html directly from the document as a blog and other content, you can use this type, there is no need for the latter For all help for rich text, please see the official documentation: Rich Text Processing In fact, Qt provides related classes: QTextDocument rich text document, QTextBlock Text fast, QTextFrame frame, QTextTable table, QTextList list, QTextCursor pointer position, QTextXXXXFormat various data type styles. What can be determined is that the rich text editor should use QTextEdit or QPlainTextEdit, but it must not actively write html code or process the display format one by one to achieve rich text.

  • QTextBrowser: Inherited from QTextEdit, only provides display function, and provides hypertext navigation function, if you do not need hypertext connection only need to use QTextEdit and set QTextEdit::setReadOnly.
  • QPlainTextEdit: Plain text editor, using technology similar to textedit and optimized for plain text editing, and has the concept of article paragraphs also provides functions such as undo, but does not support html display.
  • QTextEdit: Rich text editor, support html display, you can use sethtml / tohtml for html text operation or use, also available setPlainText, toPlainText for plain text operations.
  • qt plain text editor

    QLineEdit: Single-line text input, such as simple short or single-character string content input such as user name and password.For text editing, qt provides many controls












    Qt plain text editor