我正在尝试将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
我认为这就是我需要做的一切。我在这里缺少什么?