模块 "Qt3D.Core" 未安装

module "Qt3D.Core" is not installed

我正在尝试将 3D 功能添加到我现有的 Qt 应用程序中。在我的 project.pro 文件中,我设置了 QT 变量:

TEMPLATE = subdirs
QT += 3dcore 3drender 3dinput 3dquick qml quick 3dquickextras
SUBDIRS = plugins/datasource \
          plugins/screenManager

qml.files = apps modules sysui i18n am-config.yaml Main*.qml
INSTALLS += qml

编辑: 我将 QML_IMPORT_TRACE 环境变量设置为 1。现在,当我尝试 运行 应用程序时,我会看到以下内容:

[DBG  | default] QQmlImportDatabase::addImportPath: "/usr/lib/x86_64-linux-gnu/qt5/qml"                                                                    [:0]
[DBG  | default] QQmlImportDatabase::addImportPath: "/usr/local/Qt-5.7.0/include"                                                                          [:0]
[DBG  | default] QQmlImportDatabase::addImportPath: "/usr/local/bin"       [:0]
[DBG  | default] QQmlImportDatabase::setImportPathList: ("/usr/local/bin", "/usr/local/Qt-5.7.0/include", "/usr/lib/x86_64-linux-gnu/qt5/qml", "/home/aras/Projects/UI/imports/shared", "/home/aras/Projects/UI/imports/system") [:0]
[CRIT | am.system] WARNING: could not register service org.freedesktop.Notifications on D-Bus (unix:abstract=/tmp/dbus-c9i1pNpEVT):                        [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::addLibraryImport: "QtQuick" 2.5 as "QQ2"                                        [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::importExtension: loaded "/usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick.2/qmldir"    [:0]
[DBG  | default] QQmlImportDatabase::registerPluginTypes: "QtQuick" from "/usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick.2"                                     [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::addLibraryImport: "QtQuick.Window" 2.2 as ""                                    [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::importExtension: loaded "/usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Window.2/qmldir"                                                                             [:0]
[DBG  | default] QQmlImportDatabase::registerPluginTypes: "QtQuick.Window" from "/usr/lib/x86_64-linux-gnu/qt5/qml/QtQuick/Window.2"                       [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::addFileImport: "sysui" -1.-1 as ""                                              [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::addLibraryImport: "controls" 1.0 as ""                                          [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::importExtension: loaded "/home/aras/Projects/UI/imports/shared/controls/qmldir"                                                                            [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::addLibraryImport: "utils" 1.0 as ""                                             [:0]
[DBG  | default] QQmlImports(file:///home/aras/Projects/UI/Main.qml)::importExtension: loaded "/home/aras/Projects/UI/imports/shared/utils/qmldir"                                                                               [:0]
[WARN | default] QQmlApplicationEngine failed to load component            [:0]
[WARN | default] file:///home/aras/Projects/UI/Main.qml:6 module "Qt3D.Core" is not installed
                                                                           [:0]
[CRIT | am.system] ERROR: Qml scene does not have a root object            [:0]

Qt 安装在 /usr/local/Qt-5.7.0:

$ which qml
/usr/local/Qt-5.7.0/bin//qml
aras@aras-T900:~$ which qmake
/usr/local/Qt-5.7.0/bin//qmake

在我的 .qml 文件中,我尝试导入我需要的 3D 库:

import Qt3D.Core 2.0
import Qt3D.Render 2.0

然而,当我尝试 运行 我的应用程序时,出现了这些错误:

...module "Qt3D.Render" is not installed
...module "Qt3D.Core" is not installed

我认为这就是我需要做的。我在这里错过了什么?

我通过检查 qt 的最新源代码并构建它,在我的 qt 应用程序中使用 3D。然后当我运行陷入模块缺失的问题时,我构建相应的模块。对于 3D,我是这样做的:

cd qt3d
../qtbase/bin/qmake ../../qt5/qt3d
make -j5

这是假设在源目录之外构建。源代码在 qt5 目录中。希望这对某人有所帮助。