QTextCursor is a class in the Qt framework which provides methods to access and manipulate the text data of a QTextDocument object. One of its methods is `insertHtml`, which enables the insertion of HTML-formatted text into the document.
Example 1:
QTextEdit* textEdit = new QTextEdit;
QTextCursor cursor = textEdit->textCursor();
cursor.insertHtml("
This is a bold text
");
In this example, a new `QTextEdit` widget is created and a `QTextCursor` object is used to access its text data. The `insertHtml` method is then called with an HTML-formatted string parameter, which inserts a paragraph of text with the word "bold" in bold font.
The package library for this example is Qt.
Example 2:
QTextDocument* doc = new QTextDocument;
QTextCursor cursor(doc);
cursor.insertHtml("
Item 1
Item 2
Item 3
");
In this example, a new `QTextDocument` object is created and a `QTextCursor` object is used to manipulate its text data. The `insertHtml` method is called with an HTML-formatted string parameter containing an unordered list with three list items. This inserts the list into the document.
The package library for this example is also Qt.
C++ (Cpp) QTextCursor::insertHtml - 29 examples found. These are the top rated real world C++ (Cpp) examples of QTextCursor::insertHtml extracted from open source projects. You can rate examples to help us improve the quality of examples.