Skip to content

PythonQt.Qt.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. (shared captured text)
blockFormat function (self) -> Any X.blockFormat() -> PythonQt.QtGui.QTextBlockFormat (shared captured text)
blockFormatIndex function (self) -> int X.blockFormatIndex() -> int (shared captured text)
blockNumber function (self) -> int X.blockNumber() -> int (shared captured text)
charFormat function (self) -> Any X.charFormat() -> PythonQt.QtGui.QTextCharFormat (shared captured text)
charFormatIndex function (self) -> int X.charFormatIndex() -> int (shared captured text)
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. (shared captured text)
contains function (self, position: int) -> bool X.contains(position) -> bool (shared captured text)
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 (shared captured text)
end function (self) -> Any Returns a text block iterator pointing to the end of the text block. (shared captured text)
firstLineNumber function (self) -> int X.firstLineNumber() -> int (shared captured text)
fragmentIndex function (self) -> int X.fragmentIndex() -> int (shared captured text)
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 (shared captured text)
isVisible function (self) -> bool X.isVisible() -> bool (shared captured text)
layout function (self) -> Any X.layout() -> PythonQt.QtGui.QTextLayout (shared captured text)
length function (self) -> int X.length() -> int (shared captured text)
lineCount function (self) -> int X.lineCount() -> int (shared captured text)
next function (self) -> Any X.next() -> PythonQt.QtGui.QTextBlock (shared captured text)
position function (self) -> int X.position() -> int (shared captured text)
previous function (self) -> Any X.previous() -> PythonQt.QtGui.QTextBlock (shared captured text)
revision function (self) -> int X.revision() -> int (shared captured text)
setLineCount function (self, count: int) -> None Sets the line count to count. (shared captured text)
setRevision function (self, rev: int) -> None Sets a blocks revision to rev. (shared captured text)
setUserData function (self, data: Any) -> None Attaches the given data object to the text block. (shared captured text)
setUserState function (self, state: int) -> None Stores the specified state integer value in the text block. (shared captured text)
setVisible function (self, visible: bool) -> None Sets the block's visibility to visible. (shared captured text)
text function (self) -> str X.text() -> str (shared captured text)
textDirection function (self) -> Any Returns the resolved text direction. (shared captured text)
textFormats function (self) -> tuple X.textFormats() -> tuple (shared captured text)
textList function (self) -> Any X.textList() -> PythonQt.QtGui.QTextList (shared captured text)
userData function (self) -> Any X.userData() -> PythonQt.QtGui.QTextBlockUserData (shared captured text)
userState function (self) -> int X.userState() -> int (shared captured text)