- Extending Qt Creator Manual
- QtCreator
- PlainTextDocumentLayout
- Extending Qt Creator Manual 20.0.2

# Utils::PlainTextDocumentLayout Class

class Utils::PlainTextDocumentLayout

The PlainTextDocumentLayout class implements a plain text layout for QTextDocument. More...

Header: | `#include <PlainTextDocumentLayout>`

- List of all members, including inherited members

## Properties

- cursorWidth : int

## Public Functions

| PlainTextDocumentLayout(QTextDocument *document)
| ~PlainTextDocumentLayout()
int | cursorWidth() const
QSizeF | documentSize() const
void | draw(QPainter *, const int &) override
int | hitTest(const QPointF &, Qt::HitTestAccuracy) const
int | pageCount() const
void | requestUpdate()
void | setCursorWidth(int width)

## Protected Functions

void | documentChanged(int from, int charsRemoved, int charsAdded)

## Detailed Description

A PlainTextDocumentLayout is required for text documents that can be display or edited in a PlainTextEdit. See QTextDocument::setDocumentLayout().

PlainTextDocumentLayout 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.

## Property Documentation

### cursorWidth : int

This property specifies the width of the cursor in pixels. The default value is 1.

Access functions:

int | cursorWidth() const
void | setCursorWidth(int width)

## Member Function Documentation

### PlainTextDocumentLayout::PlainTextDocumentLayout(QTextDocument *document)

Constructs a plain text document layout for the text document.

### `[noexcept]` PlainTextDocumentLayout::~PlainTextDocumentLayout()

Destructs a plain text document layout.

### `[protected]` void PlainTextDocumentLayout::documentChanged(int from, int charsRemoved, int charsAdded)

### QSizeF PlainTextDocumentLayout::documentSize() const

### void PlainTextDocumentLayout::draw(QPainter *, const int &)

### int PlainTextDocumentLayout::hitTest(const QPointF &, Qt::HitTestAccuracy) const

### int PlainTextDocumentLayout::pageCount() const

### void PlainTextDocumentLayout::requestUpdate()

Requests a complete update on all views.