PySide.QtGui.QTextBlockFormat class provides formatting information for blocks of text in a PySide.QtGui.QTextDocument .
A document is composed of a list of blocks, represented by PySide.QtGui.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 PySide.QtGui.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 PySide.QtGui.QTextBlockFormat.setAlignment() . Margins are controlled by PySide.QtGui.QTextBlockFormat.setTopMargin() , PySide.QtGui.QTextBlockFormat.setBottomMargin() , PySide.QtGui.QTextBlockFormat.setLeftMargin() , PySide.QtGui.QTextBlockFormat.setRightMargin() . Overall indentation is set with PySide.QtGui.QTextBlockFormat.setIndent() , the indentation of the first line with PySide.QtGui.QTextBlockFormat.setTextIndent() .
Line spacing is set with PySide.QtGui.QTextBlockFormat.setLineHeight() and retrieved via PySide.QtGui.QTextBlockFormat.lineHeight() and PySide.QtGui.QTextBlockFormat.lineHeightType() . The types of line spacing available are in the QTextBlockFormat.LineHeightTypes 枚举。
Line breaking can be enabled and disabled with PySide.QtGui.QTextBlockFormat.setNonBreakableLines() .
The brush used to paint the paragraph's background is set with PySide.QtGui.QTextFormat.setBackground() , and other aspects of the text's appearance can be customized by using the PySide.QtGui.QTextFormat.setProperty() 函数采用 OutlinePen , ForegroundBrush ,和 BackgroundBrush QTextFormat.Property 值。
If a text block is part of a list, it can also have a list format that is accessible with the listFormat() function.
| 参数: |
|
|---|
构造新 PySide.QtGui.QTextBlockFormat .
Creates a new block format with the same attributes as the given text format.
This enum describes the various types of line spacing support paragraphs can have.
| 常量 | 描述 |
|---|---|
| QTextBlockFormat.SingleHeight | This is the default line height: single spacing. |
| QTextBlockFormat.ProportionalHeight | This sets the spacing proportional to the line (in percentage). For example, set to 200 for double spacing. |
| QTextBlockFormat.FixedHeight | This sets the line height to a fixed line height (in pixels). |
| QTextBlockFormat.MinimumHeight | This sets the minimum line height (in pixels). |
| QTextBlockFormat.LineDistanceHeight | This adds the specified height between lines (in pixels). |
注意
This enum was introduced or modified in Qt 4.8
| 返回类型: | PySide.QtCore.Qt.Alignment |
|---|
返回段落的对齐方式。
| 返回类型: | PySide.QtCore.qreal |
|---|
返回段落的底边距。
| 返回类型: | PySide.QtCore.int |
|---|
Returns the paragraph's indent.
| 返回类型: | PySide.QtCore.qreal |
|---|
Returns the paragraph's left margin.
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.qreal |
Returns the height of the lines in the paragraph based on the height of the script line given by scriptLineHeight and the specified scaling factor.
The value that is returned is also dependent on the given LineHeightType of the paragraph as well as the LineHeight 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.
另请参阅
QTextBlockFormat.LineHeightTypes PySide.QtGui.QTextBlockFormat.setLineHeight() PySide.QtGui.QTextBlockFormat.lineHeightType()
| 返回类型: | PySide.QtCore.qreal |
|---|
This returns the LineHeight property for the paragraph.
另请参阅
QTextBlockFormat.LineHeightTypes PySide.QtGui.QTextBlockFormat.setLineHeight() PySide.QtGui.QTextBlockFormat.lineHeightType()
| 返回类型: | PySide.QtCore.int |
|---|
This returns the LineHeightType property of the paragraph.
另请参阅
QTextBlockFormat.LineHeightTypes PySide.QtGui.QTextBlockFormat.setLineHeight() PySide.QtGui.QTextBlockFormat.lineHeight()
| 返回类型: | PySide.QtCore.bool |
|---|
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
| 返回类型: | PySide.QtGui.QTextFormat.PageBreakFlags |
|---|
Returns the currently set page break policy for the paragraph. The default is QTextFormat.PageBreak_Auto .
| 返回类型: | PySide.QtCore.qreal |
|---|
Returns the paragraph's right margin.
| 参数: | alignment – PySide.QtCore.Qt.Alignment |
|---|
| 参数: | margin – PySide.QtCore.qreal |
|---|
Sets the paragraph's bottom margin .
| 参数: | indent – PySide.QtCore.int |
|---|
Sets the paragraph's indentation . Margins are set independently of indentation with PySide.QtGui.QTextBlockFormat.setLeftMargin() and PySide.QtGui.QTextBlockFormat.setTextIndent() 。 indentation is an integer that is multiplied with the document-wide standard indent, resulting in the actual indent of the paragraph.
| 参数: | margin – PySide.QtCore.qreal |
|---|
Sets the paragraph's left margin . Indentation can be applied separately with PySide.QtGui.QTextBlockFormat.setIndent() .
| 参数: |
|
|---|
Sets the line height for the paragraph to the value given by height which is dependent on heightType in the way described by the QTextBlockFormat.LineHeightTypes 枚举。
另请参阅
QTextBlockFormat.LineHeightTypes PySide.QtGui.QTextBlockFormat.lineHeight() PySide.QtGui.QTextBlockFormat.lineHeightType()
| 参数: | b – PySide.QtCore.bool |
|---|
若 b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.
| 参数: | flags – PySide.QtGui.QTextFormat.PageBreakFlags |
|---|
| 参数: | margin – PySide.QtCore.qreal |
|---|
Sets the paragraph's right margin .
| 参数: | tabs – |
|---|
| 参数: | aindent – PySide.QtCore.qreal |
|---|
设置 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.
| 参数: | margin – PySide.QtCore.qreal |
|---|
Sets the paragraph's top margin .
| 返回类型: |
|---|
Returns a list of tab positions defined for the text block.
| 返回类型: | PySide.QtCore.qreal |
|---|
Returns the paragraph's text indent.
| 返回类型: | PySide.QtCore.qreal |
|---|
Returns the paragraph's top margin.