QTextBlockFormat Class Reference
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument.
- #include <QTextBlockFormat>
Inherits: QTextFormat.
Note: All functions in this class are reentrant.
Detailed Description
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument.
A document is composed of a list of blocks, represented by QTextBlock objects. Each block can contain an item of some kind, such as a paragraph of text, a table, a list, or an image. Every block has an associated QTextBlockFormat that specifies its characteristics.
To cater for left-to-right and right-to-left languages you can set a block's direction with setDirection(). Paragraph alignment is set with setAlignment(). Margins are controlled by setTopMargin(), setBottomMargin(), setLeftMargin(), setRightMargin(). Overall indentation is set with setIndent(), the indentation of the first line with setTextIndent().
Line breaking can be enabled and disabled with setNonBreakableLines().
The brush used to paint the paragraph's background is set with setBackground(), and other aspects of the text's appearance can be customized by using the setProperty() function with the OutlinePen, ForegroundBrush, and BackgroundBrush QTextFormat::Property values.
If a text block is part of a list, it can also have a list format that is accessible with the listFormat() function.
See also QTextBlock and QTextCharFormat.
Public Functions
| Toggle details | QTextBlockFormat | |
Constructs a new QTextBlockFormat. | ||
Look up this member in the source code. | ||
| Toggle details | Qt::Alignment QTextBlockFormat | alignmentalignment () ()const |
Returns the paragraph's alignment. See also setAlignment(). | ||
Look up this member in the source code. | ||
| Toggle details | qreal QTextBlockFormat | bottomMarginbottomMargin () ()const |
Returns the paragraph's bottom margin. See also setBottomMargin() and topMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | int QTextBlockFormat | indentindent () ()const |
Returns the paragraph's indent. See also setIndent(). | ||
Look up this member in the source code. | ||
| Toggle details | bool QTextBlockFormat | isValidisValid () ()const |
Returns true if this block format is valid; otherwise returns false. | ||
Look up this member in the source code. | ||
| Toggle details | qreal QTextBlockFormat | leftMarginleftMargin () ()const |
Returns the paragraph's left margin. See also setLeftMargin(), rightMargin(), and indent(). | ||
Look up this member in the source code. | ||
| Toggle details | bool QTextBlockFormat | nonBreakableLinesnonBreakableLines () ()const |
Returns true if the lines in the paragraph are non-breakable; otherwise returns false. See also setNonBreakableLines(). | ||
Look up this member in the source code. | ||
| Toggle details | PageBreakFlags QTextBlockFormat | pageBreakPolicypageBreakPolicy () ()const |
Returns the currently set page break policy for the paragraph. The default is QTextFormat::PageBreak_Auto. See also setPageBreakPolicy(). | ||
Look up this member in the source code. | ||
| Toggle details | qreal QTextBlockFormat | rightMarginrightMargin () ()const |
Returns the paragraph's right margin. See also setRightMargin() and leftMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setAlignmentsetAlignment ( Qt::Alignment alignment ) ( Qt::Alignment alignment ) |
Sets the paragraph's alignment. See also alignment(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setBottomMarginsetBottomMargin ( qreal margin ) ( qreal margin ) |
Sets the paragraph's bottom margin. See also bottomMargin(), setTopMargin(), setLeftMargin(), and setRightMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setIndentsetIndent ( int indentation ) ( int indentation ) |
Sets the paragraph's indentation. Margins are set independently of indentation with setLeftMargin() and setTextIndent(). The indentation is an integer that is multiplied with the document-wide standard indent, resulting in the actual indent of the paragraph. See also indent() and QTextDocument::indentWidth(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setLeftMarginsetLeftMargin ( qreal margin ) ( qreal margin ) |
Sets the paragraph's left margin. Indentation can be applied separately with setIndent(). See also leftMargin(), setRightMargin(), setTopMargin(), and setBottomMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setNonBreakableLinessetNonBreakableLines ( bool b ) ( bool b ) |
If b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable. See also nonBreakableLines(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setPageBreakPolicysetPageBreakPolicy ( PageBreakFlags policy ) ( PageBreakFlags policy ) |
Sets the page break policy for the paragraph to policy. See also pageBreakPolicy(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setRightMarginsetRightMargin ( qreal margin ) ( qreal margin ) |
Sets the paragraph's right margin. See also rightMargin(), setLeftMargin(), setTopMargin(), and setBottomMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setTabPositionssetTabPositions ( const QList <QTextOption::Tab > &tabs ...) ( const QList <QTextOption::Tab > &tabs ) |
Sets the tab positions for the text block to those specified by tabs. See also tabPositions(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setTextIndentsetTextIndent ( qreal indent ) ( qreal indent ) |
Sets the indent for the first line in the block. This allows the first line of a paragraph to be indented differently to the other lines, enhancing the readability of the text. See also textIndent(), setLeftMargin(), setRightMargin(), setTopMargin(), and setBottomMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | void QTextBlockFormat | setTopMarginsetTopMargin ( qreal margin ) ( qreal margin ) |
Sets the paragraph's top margin. See also topMargin(), setBottomMargin(), setLeftMargin(), and setRightMargin(). | ||
Look up this member in the source code. | ||
| Toggle details | QList <QTextOption::Tab > QTextBlockFormat | tabPositionstabPositions () ()const |
Returns a list of tab positions defined for the text block. See also setTabPositions(). | ||
Look up this member in the source code. | ||
| Toggle details | qreal QTextBlockFormat | textIndenttextIndent () ()const |
Returns the paragraph's text indent. See also setTextIndent(). | ||
Look up this member in the source code. | ||
| Toggle details | qreal QTextBlockFormat | topMargintopMargin () ()const |
Returns the paragraph's top margin. See also setTopMargin() and bottomMargin(). | ||
Look up this member in the source code. | ||


No notes