QML 术语词汇表

常见术语

术语 定义
QML 编写 QML 应用程序的语言。语言体系结构和引擎由 Qt QML 模块实现。
Qt Quick QML 语言类型和功能的标准库,由 Qt Quick 模块提供,可以访问采用 "import QtQuick ".
类型 在 QML, type 可以引用 Value Type QML 对象类型 .

QML 语言提供了许多内置 值类型 ,和 Qt Quick 模块提供各种 Qt Quick 类型 为构建 QML 应用程序。类型也可以由第 3 方开发者提供透过 ( 模块 ) 或由应用程序开发者在应用程序自身透过 QML 文档 .

QML 类型系统 了解更多细节。

Value Type A 值类型 是简单类型,譬如 int , string and bool 。不像 对象类型 , an object cannot be instantiated from a value type; for example, it is not possible to create an int object with properties, methods, signals and so on.

Value types as well as object types usually belong to a QML 模块 . You have to import the module to use them. Some types are built into the language, for example int, bool, double, string, but also QtObject and Component.

QML 类型系统 了解更多细节。

对象类型 A QML 对象类型 是可以通过 QML 引擎实例化的类型。

A QML type can be defined either by a document in a .qml file beginning with a capital letter, or by a QObject -based C++ class.

QML 类型系统 了解更多细节。

对象 QML 对象是实例化的 QML 对象类型 .

Such objects are created by the engine when it processes 对象声明 , which specify the objects to be created and the attributes that are to be defined for each object.

Additionally, objects can be dynamically created at runtime through Component.createObject() and Qt.createQmlObject().

另请参阅 惰性实例化 .

组件

A component is a template from which a QML object or object tree is created. It is produced when a document is loaded by the QML engine. Once it has been loaded, it can be used to instantiate the object or object tree that it represents.

此外, Component type is a special type that can can be used to declare a component inline within a document. Component objects can also be dynamically created through Qt.createComponent() to dynamically create QML objects.

Document A QML Document is a self contained piece of QML source code that begins with one or more import statements and contains a single top-level object declaration. A document may reside in a .qml file or a text string.

If it is placed in a .qml file whose name begins with a capital letter, the file is recognized by the engine as a definition of a QML type. The top-level object declaration encapsulates the object tree that will be instantiated by the type.

特性

A property is an attribute of an object type that has a name and an associated value; this value can be read (and in most cases, also written to) externally.

An object can have one or more properties. Some properties are associated with the canvas (e.g., x, y, width, height, and opacity) while others may be data specific to that type (e.g., the "text" property of the Text type).

QML 对象属性 了解更多细节。

绑定

A binding is a JavaScript expression which is "bound" to a property. The value of the property at any point in time will be the value returned by evaluating that expression.

特性绑定 了解更多细节。

信号 A signal is a notification from a QML object. When an object emits a signal, other objects can receive and process this signal through a 信号处理程序 .

Most properties of QML objects have a change signal, and also an associated change signal handler which may be defined by clients to implement functionality. For example, the "onClicked()" handler of an instance of the MouseArea type might be defined in an application to cause a sound to be played.

信号和处理程序事件系统 了解更多细节。

信号处理程序

A signal handler is the expression (or function) which is triggered by a signal. It is also known as a "slot" in C++.

信号和处理程序事件系统 了解更多细节。

惰性实例化 Object instances can be instantiated "lazily" at run-time, to avoid performing unnecessary work until needed. Qt Quick provides the Loader type to make lazy instantiation more convenient.