Qt Quick Controls 1 - Text Editor Example

A QML app using Qt Quick Controls and a C++ class to provide a fully-functional rich-text editor application.

警告: 從 Qt 5.12 起棄用 Qt Quick Controls 1 模塊。使用最新 Qt Quick Controls 模塊代替。

The Text Editor Example presents a sample HTML file using the TextArea control, preserving the HTML formatting. It uses a C++ class to handle the document by providing options to open, format, and edit. The app also lets you open and edit a plain text files.

The C++ class, DocumentHandler, extends QObject and is registered as a QML type under the namespace, " org.qtproject.example 1.0 ".

The following snippets show how the type is registered under a namespace and later imported by main.qml .

QML type registration:

#include <QtQml/qqml.h>
...
qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler");
...
					

QML namespace import:

import org.qtproject.example 1.0
					

For more information about registering C++ classes as QML types, see 從 C++ 定義 QML 類型 .

運行範例

要運行範例從 Qt Creator ,打開 歡迎 模式,然後選擇範例從 範例 。更多信息,拜訪 構建和運行範例 .

範例工程 @ code.qt.io