
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQTextBlockFormat class provides formatting information for blocks of text in aQTextDocument.More...
| Header: | #include <QTextBlockFormat> |
| Inherits: | QTextFormat |
Note: All functions in this class arereentrant.
| enum | LineHeightTypes { SingleHeight, ProportionalHeight, FixedHeight, MinimumHeight, LineDistanceHeight } |
| QTextBlockFormat() | |
| Qt::Alignment | alignment() const |
| qreal | bottomMargin() const |
| int | indent() const |
| bool | isValid() const |
| qreal | leftMargin() const |
| qreal | lineHeight(qreal scriptLineHeight, qreal scaling) const |
| qreal | lineHeight() const |
| int | lineHeightType() const |
| bool | nonBreakableLines() const |
| PageBreakFlags | pageBreakPolicy() const |
| qreal | rightMargin() const |
| void | setAlignment(Qt::Alignment alignment) |
| void | setBottomMargin(qreal margin) |
| void | setIndent(int indentation) |
| void | setLeftMargin(qreal margin) |
| void | setLineHeight(qreal height, int heightType) |
| void | setNonBreakableLines(bool b) |
| void | setPageBreakPolicy(PageBreakFlags policy) |
| void | setRightMargin(qreal margin) |
| void | setTabPositions(const QList<QTextOption::Tab> & tabs) |
| void | setTextIndent(qreal indent) |
| void | setTopMargin(qreal margin) |
| QList<QTextOption::Tab> | tabPositions() const |
| qreal | textIndent() const |
| qreal | topMargin() const |
TheQTextBlockFormat class provides formatting information for blocks of text in aQTextDocument.
A document is composed of a list of blocks, represented byQTextBlock 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 associatedQTextBlockFormat 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 withsetAlignment(). Margins are controlled bysetTopMargin(),setBottomMargin(),setLeftMargin(),setRightMargin(). Overall indentation is set withsetIndent(), the indentation of the first line withsetTextIndent().
Line spacing is set withsetLineHeight() and retrieved vialineHeight() andlineHeightType(). The types of line spacing available are in theLineHeightTypes enum.
Line breaking can be enabled and disabled withsetNonBreakableLines().
The brush used to paint the paragraph's background is set withsetBackground(), and other aspects of the text's appearance can be customized by using thesetProperty() function with theOutlinePen,ForegroundBrush, andBackgroundBrushQTextFormat::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 alsoQTextBlock andQTextCharFormat.
This enum describes the various types of line spacing support paragraphs can have.
| Constant | Value | Description |
|---|---|---|
QTextBlockFormat::SingleHeight | 0 | This is the default line height: single spacing. |
QTextBlockFormat::ProportionalHeight | 1 | This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing. |
QTextBlockFormat::FixedHeight | 2 | This sets the line height to a fixed line height (in pixels). |
QTextBlockFormat::MinimumHeight | 3 | This sets the minimum line height (in pixels). |
QTextBlockFormat::LineDistanceHeight | 4 | This adds the specified height between lines (in pixels). |
This enum was introduced or modified in Qt 4.8.
See alsolineHeight(),lineHeightType(), andsetLineHeight().
Constructs a newQTextBlockFormat.
Returns the paragraph's alignment.
See alsosetAlignment().
Returns the paragraph's bottom margin.
See alsosetBottomMargin() andtopMargin().
Returns the paragraph's indent.
See alsosetIndent().
Returns true if this block format is valid; otherwise returns false.
Returns the paragraph's left margin.
See alsosetLeftMargin(),rightMargin(), andindent().
Returns the height of the lines in the paragraph based on the height of the script line given byscriptLineHeight and the specifiedscaling factor.
The value that is returned is also dependent on the givenLineHeightType of the paragraph as well as theLineHeight setting that has been set for the paragraph.
The scaling is needed for heights that include a fixed number of pixels, to scale them appropriately for printing.
This function was introduced in Qt 4.8.
See alsoLineHeightTypes,setLineHeight(), andlineHeightType().
This returns theLineHeight property for the paragraph.
This function was introduced in Qt 4.8.
See alsoLineHeightTypes,setLineHeight(), andlineHeightType().
This returns theLineHeightType property of the paragraph.
This function was introduced in Qt 4.8.
See alsoLineHeightTypes,setLineHeight(), andlineHeight().
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
See alsosetNonBreakableLines().
Returns the currently set page break policy for the paragraph. The default isQTextFormat::PageBreak_Auto.
This function was introduced in Qt 4.2.
See alsosetPageBreakPolicy().
Returns the paragraph's right margin.
See alsosetRightMargin() andleftMargin().
Sets the paragraph'salignment.
See alsoalignment().
Sets the paragraph's bottommargin.
See alsobottomMargin(),setTopMargin(),setLeftMargin(), andsetRightMargin().
Sets the paragraph'sindentation. Margins are set independently of indentation withsetLeftMargin() andsetTextIndent(). Theindentation is an integer that is multiplied with the document-wide standard indent, resulting in the actual indent of the paragraph.
See alsoindent() andQTextDocument::indentWidth().
Sets the paragraph's leftmargin. Indentation can be applied separately withsetIndent().
See alsoleftMargin(),setRightMargin(),setTopMargin(), andsetBottomMargin().
Sets the line height for the paragraph to the value given byheight which is dependent onheightType in the way described by theLineHeightTypes enum.
This function was introduced in Qt 4.8.
See alsoLineHeightTypes,lineHeight(), andlineHeightType().
Ifb is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.
See alsononBreakableLines().
Sets the page break policy for the paragraph topolicy.
This function was introduced in Qt 4.2.
See alsopageBreakPolicy().
Sets the paragraph's rightmargin.
See alsorightMargin(),setLeftMargin(),setTopMargin(), andsetBottomMargin().
Sets the tab positions for the text block to those specified bytabs.
This function was introduced in Qt 4.4.
See alsotabPositions().
Sets theindent 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 alsotextIndent(),setLeftMargin(),setRightMargin(),setTopMargin(), andsetBottomMargin().
Sets the paragraph's topmargin.
See alsotopMargin(),setBottomMargin(),setLeftMargin(), andsetRightMargin().
Returns a list of tab positions defined for the text block.
This function was introduced in Qt 4.4.
See alsosetTabPositions().
Returns the paragraph's text indent.
See alsosetTextIndent().
Returns the paragraph's top margin.
See alsosetTopMargin() andbottomMargin().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.