QTextFrame Class
The QTextFrame class represents a frame in a QTextDocument. 更多...
头文件: | #include <QTextFrame> |
qmake: | QT += gui |
基类: | QTextObject |
派生类: |
Note: All functions in this class are reentrant.
公有类型
公有函数
QTextFrame(QTextDocument *document) | |
~QTextFrame() | |
iterator | begin() const |
QList<QTextFrame *> | childFrames() const |
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) |
- 4 个公有函数继承自 QTextObject
- 32 个公有函数继承自 QObject
其他继承的成员
- 1 个属性继承自 QObject
- 1 个公有槽函数继承自 QObject
- 2 个信号继承自 QObject
- 1 个公有变量继承自 QObject
- 10 个静态公有成员继承自 QObject
- 1 个受保护的函数继承自 QTextObject
- 9 个受保护的函数继承自 QObject
- 2 个受保护的变量继承自 QObject
详细描述
The QTextFrame class represents a frame in a QTextDocument.
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() 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 QTextFrame::iterator class: this provides read-only access to its internal list of text blocks and child frames.
参见 QTextCursor and QTextDocument.
成员函数
QTextFrame::QTextFrame(QTextDocument *document)
Creates a new empty frame for the text document.
QTextFrame::~QTextFrame()
Destroys the text frame.
Warning: 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
.
iterator QTextFrame::begin() const
Returns an iterator pointing to the first document element inside the frame. Please see the document STL-style-Iterators for more information.
参见 end().
QList<QTextFrame *> QTextFrame::childFrames() const
Returns a (possibly empty) list of the frame's child frames.
参见 parentFrame().
iterator QTextFrame::end() const
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.
参见 begin().
QTextCursor QTextFrame::firstCursorPosition() const
Returns the first cursor position inside the frame.
参见 lastCursorPosition(), firstPosition(), and lastPosition().
int QTextFrame::firstPosition() const
Returns the first document position inside the frame.
参见 lastPosition(), firstCursorPosition(), and lastCursorPosition().
QTextFrameFormat QTextFrame::frameFormat() const
Returns the frame's format.
参见 setFrameFormat().
QTextCursor QTextFrame::lastCursorPosition() const
Returns the last cursor position inside the frame.
参见 firstCursorPosition(), firstPosition(), and lastPosition().
int QTextFrame::lastPosition() const
Returns the last document position inside the frame.
参见 firstPosition(), firstCursorPosition(), and lastCursorPosition().
QTextFrame *QTextFrame::parentFrame() const
Returns the frame's parent frame. If the frame is the root frame of a document, this will return 0.
参见 childFrames() and QTextDocument::rootFrame().
void QTextFrame::setFrameFormat(const QTextFrameFormat &format)
Sets the frame's format.
参见 frameFormat().