このページでは

「Hello Vulkan」ウィジェットの例

QWidget アプリケーションにおけるQVulkanWindow の使用例を示します。

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

画像の内容が表示されたウィンドウ、色の形式を示すラベル、および取得・終了用のボタンが表示された例のスクリーンショット

Vulkanパイプラインの設定および三角形の描画を行うコードは、hellovulkantriangle と同じです。 さらに、このサンプルではQVulkanWindow のもう1つの機能、つまりカラーバッファからQImage へ画像コンテンツを読み戻す方法も示しています。「Grab」ボタンをクリックすると、サンプルは次のフレームをレンダリングし、その直後に転送操作を実行して、スワップチェーンのカラーバッファの内容をホストがアクセス可能なメモリにコピーします。その後、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.