An example for the TableView 控件。
警告: 从 Qt 5.12 起弃用 Qt Quick Controls 1 模块。使用最新 Qt Quick Controls 模块代替。
This example project demonstrates the usage of TableView from Qt Quick Controls 1 - a control to display one or more columns of information from a data list model. The example includes a model that supports sorting and filtering.
The C++ class, SortFilterProxyModel, 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<SortFilterProxyModel>("org.qtproject.example", 1, 0, "SortFilterProxyModel"); ...
QML namespace import:
import org.qtproject.example 1.0
For more information about registering C++ classes as QML types, see 从 C++ 定义 QML 类型 .
要运行范例从 Qt Creator ,打开 欢迎 模式,然后选择范例从 范例 。更多信息,拜访 构建和运行范例 .