11int main(
int argc,
char *argv[])
13 QApplication app(argc, argv);
14 QTextEdit *editor =
new QTextEdit();
16 QTextCursor cursor(editor->textCursor());
17 cursor.movePosition(QTextCursor::Start);
19 QTextCharFormat plainFormat(cursor.charFormat());
21 QTextCharFormat headingFormat = plainFormat;
22 headingFormat.setFontWeight(QFont::Bold);
23 headingFormat.setFontPointSize(16);
25 QTextCharFormat emphasisFormat = plainFormat;
26 emphasisFormat.setFontItalic(
true);
28 QTextCharFormat qtFormat = plainFormat;
29 qtFormat.setForeground(QColor(
"#990000"));
31 QTextCharFormat underlineFormat = plainFormat;
32 underlineFormat.setFontUnderline(
true);
35 cursor.insertText(tr(
"Character formats"),
40 cursor.insertText(tr(
"Text can be displayed in a variety of "
41 "different character formats. "), plainFormat);
42 cursor.insertText(tr(
"We can emphasize text by "));
43 cursor.insertText(tr(
"making it italic"), emphasisFormat);
45 cursor.insertText(tr(
", give it a "), plainFormat);
46 cursor.insertText(tr(
"different color "), qtFormat);
47 cursor.insertText(tr(
"to the default text color, "), plainFormat);
48 cursor.insertText(tr(
"underline it"), underlineFormat);
49 cursor.insertText(tr(
", and use many other effects."), plainFormat);
51 editor->setWindowTitle(tr(
"Text Document Character Formats"));
52 editor->resize(320, 480);