class QQuickTextDocument

The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit. More

Inheritance diagram of PySide6.QtQuick.QQuickTextDocument

Synopsis

Properties

  • errorStringᅟ - Human-readable string describing the error that occurred during loading or saving, if any

  • modifiedᅟ - Whether the document has been modified by the user

  • sourceᅟ - The URL from which to load document contents

  • statusᅟ - The status of document loading or saving

Methods

Signals

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

This class provides access to the QTextDocument of QQuickTextEdit elements. This is provided to allow usage of the Rich Text Processing functionalities of Qt, including document modifications. It can also be used to output content, for example with QTextDocumentWriter, or provide additional formatting, for example with QSyntaxHighlighter.

class Status

Added in version 6.7.

Note

Properties can be used directly when from __feature__ import true_property is used or via accessor functions otherwise.

property errorStringᅟ: str

This property holds a human-readable string describing the error that occurred during loading or saving, if any.

By default this string is empty.

Access functions:
property modifiedᅟ: bool

This property holds whether the document has been modified by the user.

This property holds whether the document has been modified by the user since the last time it was loaded or saved. By default, this property is false.

As with QTextDocument::modified, you can set the modified property: for example, set it to false to allow setting the source property to a different URL (thus discarding the user’s changes).

See also

modified

Access functions:
property sourceᅟ: QUrl

This property holds the URL from which to load document contents.

QQuickTextDocument can handle any text format supported by Qt, loaded from any URL scheme supported by Qt.

The source property cannot be changed while the document’s modified state is true. If the user has modified the document contents, you should prompt the user whether to save() , or else discard changes by setting modified to false before setting the source property to a different URL.

Access functions:
property statusᅟ: QQuickTextDocument.Status

This property holds the status of document loading or saving.

This property holds the status of document loading or saving. It can be one of:

  • Null

  • No file has been loaded

Access functions:
__init__(parent)
Parameters:

parentQQuickItem

Constructs a QQuickTextDocument object with parent as the parent object.

errorString()
Return type:

str

Getter of property errorStringᅟ .

errorStringChanged()

Notification signal of property errorStringᅟ .

isModified()
Return type:

bool

Getter of property modifiedᅟ .

modifiedChanged()

Notification signal of property modifiedᅟ .

save()

Saves the contents to the same file and format specified by source .

Note

You can save only to a file on a mounted filesystem.

See also

source saveAs()

saveAs(url)
Parameters:

urlQUrl

Saves the contents to the file and format specified by url.

The file extension in url specifies the file format (as determined by QMimeDatabase::mimeTypeForUrl()).

Note

You can save only to a file on a mounted filesystem.

See also

source save()

setModified(modified)
Parameters:

modified – bool

See also

isModified()

Setter of property modifiedᅟ .

setSource(url)
Parameters:

urlQUrl

See also

source()

Setter of property sourceᅟ .

setTextDocument(document)
Parameters:

documentQTextDocument

Sets the given document.

The caller retains ownership of the document.

See also

textDocument()

source()
Return type:

QUrl

See also

setSource()

Getter of property sourceᅟ .

sourceChanged()

Notification signal of property sourceᅟ .

status()
Return type:

Status

Getter of property statusᅟ .

statusChanged()

Notification signal of property statusᅟ .

textDocument()
Return type:

QTextDocument

Returns a pointer to the QTextDocument object.

textDocumentChanged()

This signal is emitted when the underlying QTextDocument is replaced with a different instance.