「Hello Vulkan」ウィジェットの例
QWidget アプリケーションにおけるQVulkanWindow の使用例を示します。
「Hello Vulkan Widget」サンプルは、「hellovulkantriangle」のバリエーションであり、QWidget::createWindowContainer() を使用して、QVulkanWindow をQWidget ベースのユーザーインターフェースに組み込んでいます。

Vulkanパイプラインの設定および三角形の描画を行うコードは、hellovulkantriangle と同じです。 さらに、このサンプルではQVulkanWindow のもう1つの機能、つまりカラーバッファからQImage へ画像コンテンツを読み戻す方法も示しています。「Grab」ボタンをクリックすると、サンプルは次のフレームをレンダリングし、その直後に転送操作を実行して、スワップチェーンのカラーバッファの内容をホストがアクセス可能なメモリにコピーします。その後、QImage::save() を通じて画像がディスクに保存されます。
例の動作
このサンプルは、以下の手順で実行できます。
- Qt Creator
Welcome モードを開き、Examples からこのサンプルを選択します。詳細については、Qt Creator: チュートリアル「ビルドと実行」を参照してください。
- Qt Extension for Visual Studio Code
Command Palette から `Qt: Open Qt examples ` コマンドを実行し、リストからサンプルを選択します。詳細については、Qt Extension for Visual Studio Code: チュートリアル: ビルドと実行を参照してください。
© 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.