QPlainTextDocumentLayout 类

QPlainTextDocumentLayout 类实现纯文本布局,为 QTextDocument . 更多...

头: #include <QPlainTextDocumentLayout>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QAbstractTextDocumentLayout

特性

公共函数

QPlainTextDocumentLayout (QTextDocument * document )
virtual ~QPlainTextDocumentLayout ()
int cursorWidth () const
void ensureBlockLayout (const QTextBlock & block ) const
void requestUpdate ()
void setCursorWidth (int width )

重实现公共函数

virtual QRectF blockBoundingRect (const QTextBlock & block ) const override
virtual QSizeF documentSize () const override
virtual void draw (QPainter *, const QAbstractTextDocumentLayout::PaintContext &) override
virtual QRectF frameBoundingRect (QTextFrame *) const override
virtual int hitTest (const QPointF &, Qt::HitTestAccuracy) const override
virtual int pageCount () const override

重实现保护函数

virtual void documentChanged (int from , int charsRemoved , int charsAdded ) override

详细描述

A QPlainTextDocumentLayout is required for text documents that can be display or edited in a QPlainTextEdit 。见 QTextDocument::setDocumentLayout ().

QPlainTextDocumentLayout uses the QAbstractTextDocumentLayout API that QTextDocument requires, but redefines it partially in order to support plain text better. For instances, it does not operate on vertical pixels, but on paragraphs (called blocks) instead. The height of a document is identical to the number of paragraphs it contains. The layout also doesn't support tables or nested frames, or any sort of advanced text layout that goes beyond a list of paragraphs with syntax highlighting.

特性文档编制

cursorWidth : int

此特性指定光标的宽度 (以像素为单位)。默认值为 1。

访问函数:

int cursorWidth () const
void setCursorWidth (int width )

成员函数文档编制

QPlainTextDocumentLayout:: QPlainTextDocumentLayout ( QTextDocument * document )

构造纯文本文档布局为文本 document .

[virtual noexcept] QPlainTextDocumentLayout:: ~QPlainTextDocumentLayout ()

销毁纯文本文档布局。

[override virtual] QRectF QPlainTextDocumentLayout:: blockBoundingRect (const QTextBlock & block ) const

重实现: QAbstractTextDocumentLayout::blockBoundingRect(const QTextBlock &block) const .

[override virtual protected] void QPlainTextDocumentLayout:: documentChanged ( int from , int charsRemoved , int charsAdded )

重实现: QAbstractTextDocumentLayout::documentChanged (int position, int charsRemoved, int charsAdded).

[override virtual] QSizeF QPlainTextDocumentLayout:: documentSize () const

重实现: QAbstractTextDocumentLayout::documentSize() const .

[override virtual] void QPlainTextDocumentLayout:: draw ( QPainter *, const QAbstractTextDocumentLayout::PaintContext &)

重实现: QAbstractTextDocumentLayout::draw (QPainter *painter, const QAbstractTextDocumentLayout::PaintContext &context).

void QPlainTextDocumentLayout:: ensureBlockLayout (const QTextBlock & block ) const

Ensures that block has a valid layout

[override virtual] QRectF QPlainTextDocumentLayout:: frameBoundingRect ( QTextFrame *) const

重实现: QAbstractTextDocumentLayout::frameBoundingRect(QTextFrame *frame) const .

[override virtual] int QPlainTextDocumentLayout:: hitTest (const QPointF &, Qt::HitTestAccuracy ) const

重实现: QAbstractTextDocumentLayout::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const .

[override virtual] int QPlainTextDocumentLayout:: pageCount () const

重实现: QAbstractTextDocumentLayout::pageCount() const .

void QPlainTextDocumentLayout:: requestUpdate ()

请求对所有视图,进行完整更新。