【问题标题】:CameraLens QML component not found (M300)未找到 CameraLens QML 组件 (M300)
【发布时间】:2018-05-15 20:10:37
【问题描述】:

我正在关注*这个例子:http://doc.qt.io/qt-5/qt3drenderer-multiviewport-example.html

*将它逐行添加到新项目中,边看边查看每一件事。

但是,找不到 CameraLens QML 组件。我正在使用 QT Creator 3.6.0。

这是 .pro:

TEMPLATE = app

QT += 3dcore 3drenderer 3dquick qml quick
CONFIG += c++11

SOURCES += main.cpp

RESOURCES += qml.qrc

# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =

# Default rules for deployment.
include(deployment.pri)

这是我的 QML:

import QtQuick 2.0
import Qt3D 2.0
import Qt3D.Renderer 2.0

Entity {
    id: rootNode

    CameraLens {
        id: cameraLens
        projectionType: CameraLens.PerspectiveProjection
        fieldOfView: 45
        aspectRatio: 16/9
        nearPlane: 0.01
        farPlane: 1000.0
    }
}

据我所知,我使用的是 QT 5.5(这是我安装的唯一一个),该文档说应该包括 CameraLens:http://doc.qt.io/qt-5/qml-qt3d-cameralens.html

我不知道接下来该看什么或可能出了什么问题。

【问题讨论】:

  • 我可以运行多视口示例——但它没有出现在“示例”部分中——必须转到“示例 -> qt3d”目录并加载/构建“qt3d .pro”。我没有看到任何“CameraLens.qml”文件,也没有在定义它的 c++ 代码中看到。 Qt 示例代码有点难以导航,因为有很多共享元素等。

标签: qt qt3d


【解决方案1】:

定义在qt3dquick3dcoreplugin.cpp:

qmlRegisterType<Qt3D::QCameraLens>(uri, 2, 0, "CameraLens");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 1970-01-01
    • 2021-04-16
    • 2021-11-15
    • 2019-10-14
    • 1970-01-01
    相关资源
    最近更新 更多