Qt 3D: 簡単なQMLの例
Qt 3D でシーンを描画する方法を示すQMLアプリケーションです。

「Simple」は、Qt 3D でシーンを描画する方法を示しています。
例の動作確認
以下の手順でサンプルを実行できます:
- Qt Creator
Welcome モードを開き、Examples からこのサンプルを選択してください。詳細については、Qt Creator の「チュートリアル:ビルドと実行」を参照してください。
- Qt Extension for Visual Studio Code
Command Palette からQt: Open Qt examples コマンドを実行し、リストからこの例を選択します。詳細については、Qt Extension for Visual Studio Code の「チュートリアル: ビルドと実行」を参照してください。
シーンの設定
シーン全体はmain.qmlファイルで設定します。
Q3D および Q3D Render モジュール内の型を使用するには、これらのモジュールをインポートする必要があります:
import Qt3D.Core 2.0
import Qt3D.Render 2.0最初に作成するエンティティは、最終的なレンダリングに使用されるカメラを表す `Camera` と、キーボードやマウスを使ってこのカメラを制御するためのカメラコントローラです:
Camera {
id: camera
projectionType: CameraLens.PerspectiveProjection
fieldOfView: 45
aspectRatio: 16/9
nearPlane : 0.1
farPlane : 1000.0
position: Qt.vector3d( 0.0, 0.0, -40.0 )
upVector: Qt.vector3d( 0.0, 1.0, 0.0 )
viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )
}RenderSettings エンティティは、アクティブなフレームグラフとしてForwardRendererを指定します:
components: [
RenderSettings {
activeFrameGraph: ForwardRenderer {
clearColor: Qt.rgba(0, 0.5, 1, 1)
camera: camera
showDebugOverlay: true
}
},
// Event Source will be set by the Qt3DQuickWindow
InputSettings { }
]イベントソースは Qt3DQuickWindow によって設定されます:
InputSettings { }© 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.