QTextBlockFormat Class
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument. More...
Header: | #include <QTextBlockFormat> |
qmake: | QT += gui |
Inherits: | QTextFormat |
Note: All functions in this class are reentrant.
Public Types
enum | LineHeightTypes { SingleHeight, ProportionalHeight, FixedHeight, MinimumHeight, LineDistanceHeight } |
Public Functions
QTextBlockFormat() | |
Qt::Alignment | alignment() const |
qreal | bottomMargin() const |
int | headingLevel() 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 |
QTextFormat::PageBreakFlags | pageBreakPolicy() const |
qreal | rightMargin() const |
void | setAlignment(Qt::Alignment alignment) |
void | setBottomMargin(qreal margin) |
void | setHeadingLevel(int alevel) |
void | setIndent(int indent) |
void | setLeftMargin(qreal margin) |
void | setLineHeight(qreal height, int heightType) |
void | setNonBreakableLines(bool b) |
void | setPageBreakPolicy(QTextFormat::PageBreakFlags flags) |
void | setRightMargin(qreal margin) |
void | setTabPositions(const QList<QTextOption::Tab> &tabs) |
void | setTextIndent(qreal aindent) |
void | setTopMargin(qreal margin) |
QList<QTextOption::Tab> | tabPositions() const |
qreal | textIndent() const |
qreal | topMargin() const |
- 51 public functions inherited from QTextFormat
Protected Functions
QTextBlockFormat(const QTextFormat &fmt) |
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 spacing is set with setLineHeight() and retrieved via lineHeight() and lineHeightType(). The types of line spacing available are in the LineHeightTypes enum.
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.
Member Type Documentation
enum QTextBlockFormat::LineHeightTypes
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 also lineHeight(), lineHeightType(), and setLineHeight().
Member Function Documentation
QTextBlockFormat::QTextBlockFormat()
Default constructs an instance of QTextBlockFormat.
[protected]
QTextBlockFormat::QTextBlockFormat(const QTextFormat &fmt)
Default constructs an instance of QTextBlockFormat.
Qt::Alignment QTextBlockFormat::alignment() const
See also setAlignment().
qreal QTextBlockFormat::bottomMargin() const
See also setBottomMargin().
int QTextBlockFormat::headingLevel() const
See also setHeadingLevel().
int QTextBlockFormat::indent() const
See also setIndent().
bool QTextBlockFormat::isValid() const
qreal QTextBlockFormat::leftMargin() const
See also setLeftMargin().
qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight, qreal scaling) const
See also setLineHeight().
qreal QTextBlockFormat::lineHeight() const
int QTextBlockFormat::lineHeightType() const
bool QTextBlockFormat::nonBreakableLines() const
See also setNonBreakableLines().
QTextFormat::PageBreakFlags QTextBlockFormat::pageBreakPolicy() const
See also setPageBreakPolicy().
qreal QTextBlockFormat::rightMargin() const
See also setRightMargin().
void QTextBlockFormat::setAlignment(Qt::Alignment alignment)
See also alignment().
void QTextBlockFormat::setBottomMargin(qreal margin)
See also bottomMargin().
void QTextBlockFormat::setHeadingLevel(int alevel)
See also headingLevel().
void QTextBlockFormat::setIndent(int indent)
See also indent().
void QTextBlockFormat::setLeftMargin(qreal margin)
See also leftMargin().
void QTextBlockFormat::setLineHeight(qreal height, int heightType)
See also lineHeight().
void QTextBlockFormat::setNonBreakableLines(bool b)
See also nonBreakableLines().
void QTextBlockFormat::setPageBreakPolicy(QTextFormat::PageBreakFlags flags)
See also pageBreakPolicy().
void QTextBlockFormat::setRightMargin(qreal margin)
See also rightMargin().
void QTextBlockFormat::setTabPositions(const QList<QTextOption::Tab> &tabs)
Sets the tab positions for the text block to those specified by tabs.
This function was introduced in Qt 4.4.
See also tabPositions().
void QTextBlockFormat::setTextIndent(qreal aindent)
See also textIndent().
void QTextBlockFormat::setTopMargin(qreal margin)
See also topMargin().
QList<QTextOption::Tab> QTextBlockFormat::tabPositions() const
Returns a list of tab positions defined for the text block.
This function was introduced in Qt 4.4.
See also setTabPositions().
qreal QTextBlockFormat::textIndent() const
See also setTextIndent().
qreal QTextBlockFormat::topMargin() const
See also setTopMargin().