创建Qt Quick UI 原型

Qt Quick 用户界面原型项目可用于测试或原型用户界面,或建立一个单独的项目专门用于 QML 编辑等。您不能将其用于应用程序开发,因为它们不具备以下功能:

  • C++ 代码
  • 资源文件 (.qrc)
  • 将应用程序部署到设备所需的代码

有关如何将Qt Quick UI Prototype 项目转化为Qt Quick Application 项目的更多信息,请参阅将UI 项目转化为应用程序

创建Qt Quick UI 原型项目:

  1. 转到File >New Project >Other Project > 。 Qt Quick UI Prototype.
  2. 选择Choose ,打开Project Location 对话框。
  3. Name 中,输入应用程序的名称。
  4. Create in 中,输入项目文件的路径。选择Use as default project location 默认在此文件夹中创建新项目。
  5. 选择Next (或 macOS 上的Continue ),打开Define Project Details 对话框。
  6. 选择 Create a project that you can open in Qt Design Studio使项目与Qt Design Studio 兼容。
  7. 选择 Use Qt Virtual Keyboard复选框,在应用程序中添加对 Qt Virtual Keyboard的支持。

    注意: 如果在安装 Qt 时未安装Qt Virtual Keyboard 模块,则在尝试打开main.qml 时会出现错误信息。

  8. 选择Next 打开Kit Selection 对话框。
  9. 为要构建应用程序的平台选择工具包

    注: 如果已在首选项>Kits 中指定了工具包,则会列出这些工具包。

  10. 选择Next 打开Project Management 对话框。
  11. 查看项目设置,然后选择Finish (Windows 和 Linux)或Done (macOS)创建项目。

Qt Creator 创建以下文件:

  • .qmlproject 项目文件定义项目文件夹中的所有 QML、JavaScript 和图像文件都属于该项目。因此,无需单独列出项目中的所有文件。
  • .qml 文件定义一个用户界面项目,如组件或整个应用程序用户界面。
  • Screen01.ui.qml 文件使用构成背景的矩形类型、按钮和显示文本的文本组件的实例定义了一个自定义 QML 类型。如果选择 Create a project that you can open in Qt Design Studio.

要在应用程序中使用 JavaScript 和图像文件,请将它们复制到项目文件夹。

另请参阅 创建Qt Quick 应用程序如何管理工具包创建项目

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.