本页

QML 预览器示例

演示如何使用QWidget::createWindowContainer() 将Qt QuickQt Widgets 应用程序混合。

带实时预览面板的 QML 代码编辑器

该示例演示了如何在Qt Widgets 应用程序中嵌入Qt Quick 场景,以及如何在Qt WidgetsQt Quick 之间整合不同的用户界面。其中包括

  • Qt Widgets 和 之间的标签聚焦Qt Quick
  • Qt Widgets 和 之间的拖放Qt Quick
  • 在嵌入的 QML 文件中定义快捷方式
  • 在应用程序中嵌入QQuickView QLayout

运行示例

要运行来自 Qt Creator,打开Welcome 模式并从Examples 中选择示例。更多信息,请参阅Qt Creator: 教程:构建并运行

用户界面演示

示例的主窗口左侧包含一个文件浏览器,可让您选择要预览的 QML 文件。右侧显示QQuickWidget 中的 QML 内容。你可以与 QML 内容交互,包括点击按钮、输入文本和使用 QML 文件中定义的快捷方式。

该示例还演示了如何在Qt WidgetsQt Quick 组件之间处理焦点和输入事件,以确保流畅的用户体验。

示例项目 @ code.qt.io

另请参见 QWidget::createWindowContainer().

© 2026 The Qt Company Ltd. 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.