PySide6.QtGui.QTextFrame¶
- class QTextFrame¶
- The - QTextFrameclass represents a frame in a- QTextDocument. More_…- Inherited by: - QTextTable- Synopsis¶- Methods¶- def - __init__()
- def - __iter__()
- def - begin()
- def - childFrames()
- def - end()
- def - firstPosition()
- def - frameFormat()
- def - lastPosition()
- def - parentFrame()
- def - setFrameFormat()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- Text frames provide structure for the text in a document. They are used as generic containers for other document elements. Frames are usually created by using - insertFrame().- Frames can be used to create hierarchical structures in rich text documents. Each document has a root frame ( - rootFrame()), and each frame beneath the root frame has a parent frame and a (possibly empty) list of child frames. The parent frame can be found with- parentFrame(), and the- childFrames()function provides a list of child frames.- Each frame contains at least one text block to enable text cursors to insert new document elements within. As a result, the - iteratorclass is used to traverse both the blocks and child frames within a given frame. The first and last child elements in the frame can be found with- begin()and- end().- A frame also has a format (specified using - QTextFrameFormat) which can be set with- setFormat()and read with- format().- Text cursors can be obtained that point to the first and last valid cursor positions within a frame; use the - firstCursorPosition()and- lastCursorPosition()functions for this. The frame’s extent in the document can be found with- firstPosition()and- lastPosition().- You can iterate over a frame’s contents using the - iteratorclass: this provides read-only access to its internal list of text blocks and child frames.- See also - __init__(doc)¶
- Parameters:
- doc – - QTextDocument
 
 - Creates a new empty frame for the text - document.- __iter__()¶
- Return type:
- object 
 
 - Returns an iterator pointing to the first document element inside the frame. Please see the document STL-style-Iterators for more information. - See also - childFrames()¶
- Return type:
- .list of QTextFrame 
 
 - Returns a (possibly empty) list of the frame’s child frames. - See also - Returns an iterator pointing to the position past the last document element inside the frame. Please see the document STL-Style Iterators for more information. - See also - firstCursorPosition()¶
- Return type:
 
 - Returns the first cursor position inside the frame. - firstPosition()¶
- Return type:
- int 
 
 - Returns the first document position inside the frame. - frameFormat()¶
- Return type:
 
 - Returns the frame’s format. - See also - lastCursorPosition()¶
- Return type:
 
 - Returns the last cursor position inside the frame. - lastPosition()¶
- Return type:
- int 
 
 - Returns the last document position inside the frame. - parentFrame()¶
- Return type:
 
 - Returns the frame’s parent frame. If the frame is the root frame of a document, this will return 0. - See also - setFrameFormat(format)¶
- Parameters:
- format – - QTextFrameFormat
 
 - Sets the frame’s - format.- See also - class iterator¶
- The iterator class provides an iterator for reading the contents of a - QTextFrame. More_…- Synopsis¶- Methods¶- def - __init__()
- def - __iter__()
- def - __next__()
- def - atEnd()
- def - currentBlock()
- def - currentFrame()
- def - __ne__()
- def - __iadd__()
- def - __isub__()
- def - __eq__()
- def - parentFrame()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- A frame consists of an arbitrary sequence of - QTextBlocks and child- QTextFrames. This class provides a way to iterate over the child objects of a frame, and read their contents. It does not provide a way to modify the contents of the frame.- __init__()¶
 - Constructs an invalid iterator. - __iter__()¶
- Return type:
- object 
 
 - __next__()¶
- Return type:
- object 
 
 - atEnd()¶
- Return type:
- bool 
 
 - Returns - trueif the current item is the last item in the text frame.- currentBlock()¶
- Return type:
 
 - Returns the current block the iterator points to. If the iterator points to a child frame, the returned block is invalid. - See also - currentFrame()- currentFrame()¶
- Return type:
 
 - Returns the current frame pointed to by the iterator, or - Noneif the iterator currently points to a block.- See also - currentBlock()- Returns true if the iterator is different from the - otheriterator; otherwise returns- false.- Moves the iterator to the next frame or block. - See also - currentBlock()- currentFrame()- __iadd__(arg__1)
- Parameters:
- arg__1 – int 
- Return type:
 
 - The postfix - ++operator (- i++) advances the iterator to the next item in the text frame, and returns an iterator to the old item.- Moves the iterator to the previous frame or block. - See also - currentBlock()- currentFrame()- __isub__(arg__1)
- Parameters:
- arg__1 – int 
- Return type:
 
 - The postfix - --operator (- i--) makes the preceding item in the current frame, and returns an iterator to the old item.- Returns true if the iterator is the same as the - otheriterator; otherwise returns- false.- parentFrame()¶
- Return type:
 
 - Returns the parent frame of the current frame. - See also - currentFrame()- parentFrame()