Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QTextBlockFormat Class

TheQTextBlockFormat class provides formatting information for blocks of text in aQTextDocument.More...

Header:#include <QTextBlockFormat>
Inherits:QTextFormat

Note: All functions in this class arereentrant.

Public Types

enumLineHeightTypes { SingleHeight, ProportionalHeight, FixedHeight, MinimumHeight, LineDistanceHeight }

Public Functions

QTextBlockFormat()
Qt::Alignmentalignment() const
qrealbottomMargin() const
intindent() const
boolisValid() const
qrealleftMargin() const
qreallineHeight(qreal scriptLineHeight, qreal scaling) const
qreallineHeight() const
intlineHeightType() const
boolnonBreakableLines() const
PageBreakFlagspageBreakPolicy() const
qrealrightMargin() const
voidsetAlignment(Qt::Alignment alignment)
voidsetBottomMargin(qreal margin)
voidsetIndent(int indentation)
voidsetLeftMargin(qreal margin)
voidsetLineHeight(qreal height, int heightType)
voidsetNonBreakableLines(bool b)
voidsetPageBreakPolicy(PageBreakFlags policy)
voidsetRightMargin(qreal margin)
voidsetTabPositions(const QList<QTextOption::Tab> & tabs)
voidsetTextIndent(qreal indent)
voidsetTopMargin(qreal margin)
QList<QTextOption::Tab>tabPositions() const
qrealtextIndent() const
qrealtopMargin() const

Detailed Description

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.

Member Type Documentation

enum QTextBlockFormat::LineHeightTypes

This enum describes the various types of line spacing support paragraphs can have.

ConstantValueDescription
QTextBlockFormat::SingleHeight0This is the default line height: single spacing.
QTextBlockFormat::ProportionalHeight1This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing.
QTextBlockFormat::FixedHeight2This sets the line height to a fixed line height (in pixels).
QTextBlockFormat::MinimumHeight3This sets the minimum line height (in pixels).
QTextBlockFormat::LineDistanceHeight4This adds the specified height between lines (in pixels).

This enum was introduced or modified in Qt 4.8.

See alsolineHeight(),lineHeightType(), andsetLineHeight().

Member Function Documentation

QTextBlockFormat::QTextBlockFormat()

Constructs a newQTextBlockFormat.

Qt::Alignment QTextBlockFormat::alignment() const

Returns the paragraph's alignment.

See alsosetAlignment().

qreal QTextBlockFormat::bottomMargin() const

Returns the paragraph's bottom margin.

See alsosetBottomMargin() andtopMargin().

int QTextBlockFormat::indent() const

Returns the paragraph's indent.

See alsosetIndent().

bool QTextBlockFormat::isValid() const

Returns true if this block format is valid; otherwise returns false.

qreal QTextBlockFormat::leftMargin() const

Returns the paragraph's left margin.

See alsosetLeftMargin(),rightMargin(), andindent().

qreal QTextBlockFormat::lineHeight(qreal scriptLineHeight,qreal scaling) const

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().

qreal QTextBlockFormat::lineHeight() const

This returns theLineHeight property for the paragraph.

This function was introduced in Qt 4.8.

See alsoLineHeightTypes,setLineHeight(), andlineHeightType().

int QTextBlockFormat::lineHeightType() const

This returns theLineHeightType property of the paragraph.

This function was introduced in Qt 4.8.

See alsoLineHeightTypes,setLineHeight(), andlineHeight().

bool QTextBlockFormat::nonBreakableLines() const

Returns true if the lines in the paragraph are non-breakable; otherwise returns false.

See alsosetNonBreakableLines().

PageBreakFlags QTextBlockFormat::pageBreakPolicy() const

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().

qreal QTextBlockFormat::rightMargin() const

Returns the paragraph's right margin.

See alsosetRightMargin() andleftMargin().

void QTextBlockFormat::setAlignment(Qt::Alignment alignment)

Sets the paragraph'salignment.

See alsoalignment().

void QTextBlockFormat::setBottomMargin(qreal margin)

Sets the paragraph's bottommargin.

See alsobottomMargin(),setTopMargin(),setLeftMargin(), andsetRightMargin().

void QTextBlockFormat::setIndent(int indentation)

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().

void QTextBlockFormat::setLeftMargin(qreal margin)

Sets the paragraph's leftmargin. Indentation can be applied separately withsetIndent().

See alsoleftMargin(),setRightMargin(),setTopMargin(), andsetBottomMargin().

void QTextBlockFormat::setLineHeight(qreal height,int heightType)

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().

void QTextBlockFormat::setNonBreakableLines(bool b)

Ifb is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.

See alsononBreakableLines().

void QTextBlockFormat::setPageBreakPolicy(PageBreakFlags policy)

Sets the page break policy for the paragraph topolicy.

This function was introduced in Qt 4.2.

See alsopageBreakPolicy().

void QTextBlockFormat::setRightMargin(qreal margin)

Sets the paragraph's rightmargin.

See alsorightMargin(),setLeftMargin(),setTopMargin(), andsetBottomMargin().

void QTextBlockFormat::setTabPositions(constQList<QTextOption::Tab> & tabs)

Sets the tab positions for the text block to those specified bytabs.

This function was introduced in Qt 4.4.

See alsotabPositions().

void QTextBlockFormat::setTextIndent(qreal indent)

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().

void QTextBlockFormat::setTopMargin(qreal margin)

Sets the paragraph's topmargin.

See alsotopMargin(),setBottomMargin(),setLeftMargin(), andsetRightMargin().

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 alsosetTabPositions().

qreal QTextBlockFormat::textIndent() const

Returns the paragraph's text indent.

See alsosetTextIndent().

qreal QTextBlockFormat::topMargin() const

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.


[8]ページ先頭

©2009-2025 Movatter.jp