QTextFrame 类表示框架在 QTextDocument . 更多...
头: | #include <QTextFrame> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QTextObject |
继承者: |
注意: 此类的所有函数 可重入 .
class | iterator |
Iterator |
QTextFrame (QTextDocument * document ) | |
virtual | ~QTextFrame () |
QTextFrame::iterator | begin () const |
QList<QTextFrame *> | childFrames () const |
QTextFrame::iterator | end () const |
QTextCursor | firstCursorPosition () const |
int | firstPosition () const |
QTextFrameFormat | frameFormat () const |
QTextCursor | lastCursorPosition () const |
int | lastPosition () const |
QTextFrame * | parentFrame () const |
void | setFrameFormat (const QTextFrameFormat & format ) |
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 QTextCursor::insertFrame ().
Frames can be used to create hierarchical structures in rich text documents. Each document has a root frame ( QTextDocument::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 QTextFrame::iterator class 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 () 和 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 () 和 lastCursorPosition () functions for this. The frame's extent in the document can be found with firstPosition () 和 lastPosition ().
You can iterate over a frame's contents using the QTextFrame::iterator class: this provides read-only access to its internal list of text blocks and child frames.
另请参阅 QTextCursor and QTextDocument .
Qt 样式同义词 QTextFrame::iterator .
[explicit]
QTextFrame::
QTextFrame
(
QTextDocument
*
document
)
Creates a new empty frame for the text document .
[virtual noexcept]
QTextFrame::
~QTextFrame
()
Destroys the text frame.
警告:
Text frames are owned by the document, so you should never destroy them yourself. In order to remove a frame from its document, remove its contents using a
QTextCursor
.
Returns an iterator pointing to the first document element inside the frame. Please see the document STL-style-Iterators 了解更多信息。
另请参阅 end ().
Returns a (possibly empty) list of the frame's child frames.
另请参阅 parentFrame ().
Returns an iterator pointing to the position past the last document element inside the frame. Please see the document STL 样式迭代器 了解更多信息。
另请参阅 begin ().
Returns the first cursor position inside the frame.
另请参阅 lastCursorPosition (), firstPosition (),和 lastPosition ().
Returns the first document position inside the frame.
另请参阅 lastPosition (), firstCursorPosition (),和 lastCursorPosition ().
Returns the frame's format.
另请参阅 setFrameFormat ().
Returns the last cursor position inside the frame.
另请参阅 firstCursorPosition (), firstPosition (),和 lastPosition ().
Returns the last document position inside the frame.
另请参阅 firstPosition (), firstCursorPosition (),和 lastCursorPosition ().
Returns the frame's parent frame. If the frame is the root frame of a document, this will return 0.
另请参阅 childFrames () 和 QTextDocument::rootFrame ().
Sets the frame's format .
另请参阅 frameFormat ().