このページでは

Qt 3D: 簡単なQMLの例

Qt 3D でシーンを描画する方法を示すQMLアプリケーションです。

3Dオブジェクトのレンダリング結果のスクリーンショット

「Simple」は、Qt 3D でシーンを描画する方法を示しています。

例の動作確認

以下の手順でサンプルを実行できます:

シーンの設定

シーン全体は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 によって設定されます:

サンプルプロジェクト @ 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.