The QQuickTextDocument class provides access to the QTextDocument of QQuickTextEdit. 更多...
头: | #include <QQuickTextDocument> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick) |
qmake: | QT += quick |
实例化: | TextDocument |
继承: | QObject |
(preliminary)
errorString
: const QString
(preliminary)
modified
: bool
(preliminary)
source
: QUrl
(preliminary)
status
: const Status
QQuickTextDocument (QQuickItem * parent ) | |
QString | errorString () const |
bool | isModified () const |
(preliminary)
void
|
save () |
(preliminary)
void
|
saveAs (const QUrl & url ) |
void | setModified (bool modified ) |
void | setSource (const QUrl & url ) |
(从 6.7 起)
void
|
setTextDocument (QTextDocument * document ) |
QUrl | source () const |
QQuickTextDocument::Status | status () const |
QTextDocument * | textDocument () const |
(preliminary)
void
|
errorStringChanged () |
(preliminary)
void
|
modifiedChanged () |
(preliminary)
void
|
sourceChanged () |
(preliminary)
void
|
statusChanged () |
(从 6.7 起)
void
|
textDocumentChanged () |
This class provides access to the QTextDocument of QQuickTextEdit elements. This is provided to allow usage of the 富文本处理 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 .
[read-only, preliminary]
errorString
: const
QString
This property is under development and is subject to change.
This property holds a human-readable string describing the error that occurred during loading or saving, if any
By default this string is empty.
This property was introduced in Qt 6.7.
访问函数:
QString | errorString () const |
通知程序信号:
void | errorStringChanged () |
另请参阅 status , source , save (),和 saveAs ().
[preliminary]
modified
:
bool
This property is under development and is subject to change.
此特性保持文档是否已被用户修改
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
.
就像
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).
This property was introduced in Qt 6.7.
访问函数:
bool | isModified () const |
void | setModified (bool modified ) |
通知程序信号:
void | modifiedChanged () |
另请参阅 QTextDocument::modified .
[preliminary]
source
:
QUrl
This property is under development and is subject to change.
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.
This property was introduced in Qt 6.7.
访问函数:
QUrl | source () const |
void | setSource (const QUrl & url ) |
通知程序信号:
void | sourceChanged () |
另请参阅 QTextDocumentWriter::supportedDocumentFormats ().
[read-only, preliminary]
status
: const
Status
This property is under development and is subject to change.
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 |
Loading
|
Reading from source has begun |
Loaded
|
Reading has successfully finished |
Saving
|
File writing has begun after save () 或 saveAs () |
Saved
|
Writing has successfully finished |
ReadError
|
An error occurred while reading from source |
WriteError
|
An error occurred in save () 或 saveAs () |
NonLocalFileError
|
saveAs () was called with a URL pointing to a remote resource rather than a local file |
This property was introduced in Qt 6.7.
访问函数:
QQuickTextDocument::Status | status () const |
通知程序信号:
void | statusChanged () |
另请参阅 errorString , source , save (),和 saveAs ().
Constructs a QQuickTextDocument object with parent 作为父级对象。
[signal, preliminary]
void
QQuickTextDocument::
errorStringChanged
()
This function is under development and is subject to change.
注意: 通知程序信号对于特性 errorString .
[signal, preliminary]
void
QQuickTextDocument::
modifiedChanged
()
This function is under development and is subject to change.
注意: 通知程序信号对于特性 modified .
[invokable, preliminary]
void
QQuickTextDocument::
save
()
This function is under development and is subject to change.
Saves the contents to the same file and format specified by source .
注意: You can save only to a file on a mounted filesystem .
注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .
该函数在 Qt 6.7 引入。
[invokable, preliminary]
void
QQuickTextDocument::
saveAs
(const
QUrl
&
url
)
This function is under development and is subject to change.
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 ()).
注意: You can save only to a file on a mounted filesystem .
注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .
该函数在 Qt 6.7 引入。
[since 6.7]
void
QQuickTextDocument::
setTextDocument
(
QTextDocument
*
document
)
设置给定 document .
The caller retains ownership of the document.
该函数在 Qt 6.7 引入。
另请参阅 textDocument ().
[signal, preliminary]
void
QQuickTextDocument::
sourceChanged
()
This function is under development and is subject to change.
注意: 通知程序信号对于特性 source .
[signal, preliminary]
void
QQuickTextDocument::
statusChanged
()
This function is under development and is subject to change.
注意: 通知程序信号对于特性 status .
返回指针指向 QTextDocument 对象。
另请参阅 setTextDocument ().
[signal, since 6.7]
void
QQuickTextDocument::
textDocumentChanged
()
This signal is emitted when the underlying QTextDocument is replaced with a different instance.
该函数在 Qt 6.7 引入。
另请参阅 setTextDocument ().