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
|
| 在 QML: | 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.
該特性在 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).
該特性在 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.
該特性在 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 |
該特性在 Qt 6.7 引入。
訪問函數:
| QQuickTextDocument::Status | status () const |
通知程序信號:
| void | statusChanged () |
另請參閱 errorString , source , save (),和 saveAs ().
Constructs a QQuickTextDocument object with parent 作為父級對象。
[signal, preliminary]
void
QQuickTextDocument::
errorStringChanged
()
此函數在開發且可能改變。
注意: 通知程序信號對於特性 errorString .
[signal, preliminary]
void
QQuickTextDocument::
modifiedChanged
()
此函數在開發且可能改變。
注意: 通知程序信號對於特性 modified .
[invokable, preliminary]
void
QQuickTextDocument::
save
()
此函數在開發且可能改變。
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
)
此函數在開發且可能改變。
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
()
此函數在開發且可能改變。
注意: 通知程序信號對於特性 source .
[signal, preliminary]
void
QQuickTextDocument::
statusChanged
()
此函數在開發且可能改變。
注意: 通知程序信號對於特性 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 ().