Skip to content

PythonQt.QtGui.QTextBlock

QTextBlock

PythonQtInstanceWrapper object

Native bases: PythonQtInstanceWrapper

Supplemental documentation: Qt 5 reference:

Detailed Description

A text block encapsulates a block or paragraph of text in a QTextDocument. QTextBlock provides read-only access to the block/paragraph structure of QTextDocuments. It is mainly of use if you want to implement your own layouts for the visual representation of a QTextDocument, or if you want to iterate over a document and write out the contents in your own custom format.

Text blocks are created by their parent documents. If you need to create a new text block, or modify the contents of a document while examining its contents, use the cursor-based interface provided by QTextCursor instead.

Each text block is located at a specific position() in a document(). The contents of the block can be obtained by using the text() function. The length() function determines the block's size within the document (including formatting characters). The visual properties of the block are determined by its text layout(), its charFormat(), and its blockFormat().

The next() and previous() functions enable iteration over consecutive valid blocks in a document under the condition that the document is not modified by other means during the iteration process. Note that, although blocks are returned in sequence, adjacent blocks may come from different places in the document structure. The validity of a block can be determined by calling isValid().

QTextBlock provides comparison operators to make it easier to work with blocks: operator\=\=() compares two block for equality, operator!\=() compares two blocks for inequality, and operator\<() determines whether a block precedes another in the same document.

Source: https://doc.qt.io/archives/qt-5.15/qtextblock.html

Complete member index

Every captured member retains its own identity. Identical captured declaration text is linked once; this does not establish native inheritance or interchangeable objects.

Member Kind Signature Summary
__init__ function (self, *args: Any, **kwargs: Any) -> None Native constructor; consult class documentation for supported overloads. (shared captured text)
begin function (self) -> Any Returns a text block iterator pointing to the beginning of the text block.
blockFormat function (self) -> Any X.blockFormat() -> PythonQt.QtGui.QTextBlockFormat
blockFormatIndex function (self) -> int X.blockFormatIndex() -> int
blockNumber function (self) -> int X.blockNumber() -> int
charFormat function (self) -> Any X.charFormat() -> PythonQt.QtGui.QTextCharFormat
charFormatIndex function (self) -> int X.charFormatIndex() -> int
className function (self, *args: Any, **kwargs: Any) -> Any Return the classname of the object (shared captured text)
clearLayout function (self) -> None Clears the [QTextLayout](https://doc.qt.io/archives/qt-5.15/qtextlayout.html) that is used to lay out and display the block's contents.
contains function (self, position: int) -> bool X.contains(position) -> bool
delete function (self, *args: Any, **kwargs: Any) -> Any Deletes the C++ object (at your own risk, my friend!) (shared captured text)
document function (self) -> Any X.document() -> PythonQt.QtGui.QTextDocument
end function (self) -> Any Returns a text block iterator pointing to the end of the text block.
firstLineNumber function (self) -> int X.firstLineNumber() -> int
fragmentIndex function (self) -> int X.fragmentIndex() -> int
help function (self, *args: Any, **kwargs: Any) -> Any Shows the help of available methods for this class (shared captured text)
inherits function (self, *args: Any, **kwargs: Any) -> Any Returns if the class inherits or is of given type name (shared captured text)
isValid function (self) -> bool X.isValid() -> bool
isVisible function (self) -> bool X.isVisible() -> bool
layout function (self) -> Any X.layout() -> PythonQt.QtGui.QTextLayout
length function (self) -> int X.length() -> int
lineCount function (self) -> int X.lineCount() -> int
next function (self) -> Any X.next() -> PythonQt.QtGui.QTextBlock
position function (self) -> int X.position() -> int
previous function (self) -> Any X.previous() -> PythonQt.QtGui.QTextBlock
revision function (self) -> int X.revision() -> int
setLineCount function (self, count: int) -> None Sets the line count to count.
setRevision function (self, rev: int) -> None Sets a blocks revision to rev.
setUserData function (self, data: Any) -> None Attaches the given data object to the text block.
setUserState function (self, state: int) -> None Stores the specified state integer value in the text block.
setVisible function (self, visible: bool) -> None Sets the block's visibility to visible.
text function (self) -> str X.text() -> str
textDirection function (self) -> Any Returns the resolved text direction.
textFormats function (self) -> tuple X.textFormats() -> tuple
textList function (self) -> Any X.textList() -> PythonQt.QtGui.QTextList
userData function (self) -> Any X.userData() -> PythonQt.QtGui.QTextBlockUserData
userState function (self) -> int X.userState() -> int