用户界面文件

如果您在Qt CreatorQt Design Studio 之间切换,或在一个项目中与设计人员合作,您可能会遇到用户界面文件(.ui.qml)。这些文件只能在Qt Design Studio 中编辑。

要通过Qt Design Studio 打开 UI 文件,请在文件的右键菜单中选择Open With > UI。 Qt Design Studio打开 UI 文件。

.ui.qml 文件不支持以下功能:

  • JavaScript 块
  • 纯表达式以外的其他绑定
  • 信号处理器
  • 根组件以外的其他组件中的状态
  • 未从QQuickItem 派生的根组件或Item
  • 引用根组件的父组件

不支持以下组件:

  • 行为
  • 绑定
  • 画布
  • 着色器效果
  • 计时器
  • 转换

支持的方法

Qt Creator.ui.qml 支持 Qt QML 引擎支持的大多数 JavaScript 函数,以及 Qt QML 方法的子集。

本节列出了可在.ui.qml文件中使用的函数。

JavaScript 函数

根据经验,我们支持纯函数。它们只依赖并修改其作用域内的参数状态,因此在给定相同参数时,总是返回相同的结果。这样就可以在不破坏.ui.qml文件的情况下转换和重新格式化属性绑定。

支持以下 JavaScript 函数:

  • charAt()
  • charCodeAt()
  • concat()
  • endsWith()
  • includes()
  • indexOf()
  • isFinite()
  • isNaN()
  • lastIndexOf()
  • substring()
  • toExponential()
  • toFixed()
  • toLocaleLowerCase()
  • toLocaleString
  • toLocaleUpperCase()
  • toLowerCase()
  • toPrecision()
  • toString()
  • toUpperCase()
  • valueOf()

此外,还支持MathDate 对象的所有函数。

更多信息,请参阅JavaScript 对象和函数列表

Qt QML 方法

Qt Creator 支持颜色方法、创建特定数据类型对象的辅助方法和翻译方法。

支持以下颜色方法:

支持以下辅助方法:

支持以下翻译方法:

注意: 请勿在 UI 文件中混合使用翻译方法。

有关使用方法的更多信息,请参阅Qt QML 方法

另请参阅 Qt Quick Designer

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.