创建组件实例

Qt Quick Designer 提供了预设组件,您可以通过创建组件实例在用户界面中使用这些组件

创建组件实例

创建组件实例并编辑其属性:

  1. 将组件从Components (1) 拖到Navigator (2) 或2D (3) 视图。这将在当前组件文件中创建组件实例。
  2. Navigator 中选择组件实例,在Properties 中编辑其属性值。

    属性视图

    更多信息,请参阅设置组件基本属性

  3. 要以Qt Quick Designer 默认不支持的方式更改组件实例的外观和行为,可在Connections 视图的Properties 选项卡上定义自定义属性。

    连接视图属性 "选项卡。

    更多信息,请参阅添加自定义属性

  4. 为使用户能与组件实例交互,可将实例连接到信号。例如,你可以指定当组件实例被点击时会发生什么。如需了解更多信息,请参阅将组件连接到信号

    连接 查看连接选项卡。

  5. 要在另一个组件实例发生变化时动态更改组件实例的行为,可在Connections 视图的Bindings 选项卡上创建它们之间的绑定。更多信息,请参阅在属性之间添加绑定

    连接 "视图 "绑定 "选项卡。

  6. States 视图中添加状态,以便对一个或多个组件实例的属性值应用一系列更改。更多信息,请参阅使用状态
  7. Timeline 视图中为组件实例的属性制作动画。更多信息,请参阅创建时间轴动画

另请参阅 如何使用 UI 组件Qt Quick UI 设计,以及设计Qt Quick UI

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.