27 cursor.setBlockFormat(blockFormat);
28 cursor.insertText(
tr(
"This contains plain text inside a "
29 "text block with margins to keep it separate "
30 "from other parts of the document."));
38 cursor.setBlockFormat(backgroundFormat);
40 cursor.insertText(
tr(
"The background color of a text block can be "
41 "changed to highlight text."));
48 cursor.setBlockFormat(rightAlignedFormat);
49 cursor.insertText(
tr(
"The alignment of the text within a block is "
50 "controlled by the alignment properties of "
51 "the block itself. This text block is "
60 cursor.setBlockFormat(paragraphFormat);
61 cursor.insertText(
tr(
"Text can be formatted so that the first "
62 "line in a paragraph has its own margin. "
63 "This makes the text more readable."));
71 cursor.setBlockFormat(reverseFormat);
72 cursor.insertText(
tr(
"The direction of the text can be reversed. "
73 "This is useful for right-to-left "
76 editor->setWindowTitle(
tr(
"Text Block Formats"));
77 editor->resize(480, 480);
The QApplication class manages the GUI application's control flow and main settings.
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
The QColor class provides colors based on RGB, HSV or CMYK values.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
\macro QT_RESTRICTED_CAST_FROM_ASCII
void setLeftMargin(qreal margin)
Sets the paragraph's left margin.
void setAlignment(Qt::Alignment alignment)
Sets the paragraph's alignment.
void setBottomMargin(qreal margin)
Sets the paragraph's bottom margin.
void setRightMargin(qreal margin)
Sets the paragraph's right margin.
void setTopMargin(qreal margin)
Sets the paragraph's top margin.
void setTextIndent(qreal aindent)
Sets the indent for the first line in the block.
\reentrant \inmodule QtGui
The QTextEdit class provides a widget that is used to edit and display both plain and rich text.
QTextCursor textCursor() const
Returns a copy of the QTextCursor that represents the currently visible cursor.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document's background to the brush specified.
int main_textblock_formats(int argc, char *argv[])
QApplication app(argc, argv)
[0]