QTextDocument doc; doc.setPlainText("Hello World!");
QTextDocument doc; QTextCursor cursor = doc.textCursor(); cursor.insertHtml("Bold Text");
QTextDocument doc; QTextCursor cursor = doc.textCursor(); QTextCharFormat format; format.setFontWeight(QFont::Bold); cursor.insertText("Bold Text", format);This example sets a bold text format for the text being inserted using the QTextCharFormat class. Package/library: Qt Core.