本页内容

Hello Vulkan 控件示例

展示了在QWidget 应用程序中使用QVulkanWindow 的方法。

“Hello Vulkan”控件示例是“hellovulkantriangle”的一个变体,它通过QWidget::createWindowContainer()将QVulkanWindow 嵌入到基于QWidget 的用户界面中。

示例截图,其中包含显示图像内容的窗口、显示颜色格式的标签,以及用于抓取和退出的按钮

用于设置 Vulkan 管道和渲染三角形的代码与hellovulkantriangle 中的完全相同。 此外,本示例还演示了QVulkanWindow 的另一项功能:将图像内容从颜色缓冲区读回至QImage 。点击“抓取”按钮后,示例会渲染下一帧,并随后执行传输操作,将swapchain颜色缓冲区的内容复制到主机可访问的内存中。随后,通过QImage::save()将图像保存到磁盘。

运行示例

您可以通过以下方式运行该示例:

示例项目 @ code.qt.io

© 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.