1

我正在尝试将 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

我认为这就是我需要做的。我在这里想念什么?

4

1 回答 1

2

通过查看来自 qt 的最新源代码并构建它,我在我的 qt 应用程序中获得了 3D 工作。然后当我遇到缺少模块的问题时,我构建了相应的模块。在 3D 的情况下,这就是我所做的:

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

这是假设源目录之外的构建。源代码在qt5目录内。希望这可以帮助某人。

于 2017-02-22T22:26:40.383 回答