The 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 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() function with the OutlinePen , ForegroundBrush , and BackgroundBrushQTextFormat.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.
Parameters: |
|
---|
Constructs a new PySide.QtGui.QTextBlockFormat .
Creates a new block format with the same attributes as the given text format.
Return type: | PySide.QtCore.Qt.Alignment |
---|
Returns the paragraph’s alignment.
Return type: | PySide.QtCore.qreal |
---|
Returns the paragraph’s bottom margin.
Return type: | PySide.QtCore.int |
---|
Returns the paragraph’s indent.
Return type: | PySide.QtCore.qreal |
---|
Returns the paragraph’s left margin.
Return type: | PySide.QtCore.bool |
---|
Returns true if the lines in the paragraph are non-breakable; otherwise returns false.
Return type: | PySide.QtGui.QTextFormat.PageBreakFlags |
---|
Returns the currently set page break policy for the paragraph. The default is QTextFormat.PageBreak_Auto .
Return type: | PySide.QtCore.qreal |
---|
Returns the paragraph’s right margin.
Parameters: | alignment – PySide.QtCore.Qt.Alignment |
---|
Parameters: | margin – PySide.QtCore.qreal |
---|
Sets the paragraph’s bottom margin .
Parameters: | 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() . The indentation is an integer that is multiplied with the document-wide standard indent, resulting in the actual indent of the paragraph.
Parameters: | margin – PySide.QtCore.qreal |
---|
Sets the paragraph’s left margin . Indentation can be applied separately with PySide.QtGui.QTextBlockFormat.setIndent() .
Parameters: | b – PySide.QtCore.bool |
---|
If b is true, the lines in the paragraph are treated as non-breakable; otherwise they are breakable.
Parameters: | flags – PySide.QtGui.QTextFormat.PageBreakFlags |
---|
Parameters: | margin – PySide.QtCore.qreal |
---|
Sets the paragraph’s right margin .
Parameters: | tabs – |
---|
Parameters: | aindent – PySide.QtCore.qreal |
---|
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.
Parameters: | margin – PySide.QtCore.qreal |
---|
Sets the paragraph’s top margin .
Return type: |
---|
Returns a list of tab positions defined for the text block.
Return type: | PySide.QtCore.qreal |
---|
Returns the paragraph’s text indent.
Return type: | PySide.QtCore.qreal |
---|
Returns the paragraph’s top margin.