I have tried a simple Qt Qml example and I am not able to build it. I already googled and found a dozen similar problems, but none of the recommendations helped me. My code looks like this:
main.cpp
#include <QtGui/QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine(QUrl("qrc:main.qml"));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
main.qml
import QtQuick 2.15
import QtQuick.Controls 2.15
ApplicationWindow
{
visible: true
width: 640
height: 480
title: qsTr("Minimal Qml")
}
qml.qrc
<RCC>
<qresource prefix="/">
<file>main.qml</file>
</qresource>
</RCC>
and my CMakeLists.txt
find_package(Qt5 COMPONENTS Widgets Qml Quick REQUIRED)
qt5_add_resources(QT_RESOURCES qml.qrc)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(PROJECT "qmltest")
project(${PROJECT})
add_executable(${PROJECT} main.cpp ${QT_RESOURCES})
target_link_libraries(${PROJECT}
Qt5::WinMain
Qt5::Core
Qt5::Qml
Qt5::Quick
)
I used windeployqt to get all librarys into the right place. The programm starts on my Windows machine but the console output ends with:
QQmlApplicationEngine failed to load component
qrc:main.qml:2:1: module "QtQuick.Controls" is not installed
qrc:main.qml:1:1: module "QtQuick" is not installed
qrc:main.qml:2:1: module "QtQuick.Controls" is not installed
qrc:main.qml:1:1: module "QtQuick" is not installed
Path to the app after deploying it:
<DIR> bearer
qgenericbearerd.dll
<DIR> iconengines
qsvgicond.dll
<DIR> imageformats
qgifd.dll
qicnsd.dll
qicod.dll
qjpegd.dll
qsvgd.dll
qtgad.dll
qtiffd.dll
qwbmpd.dll
qwebpd.dll
<DIR> platforminputcontexts
qtvirtualkeyboardplugind.dll
<DIR> platforms
qwindowsd.dll
<DIR> qmltooling
qmldbg_debuggerd.dll
qmldbg_inspectord.dll
qmldbg_locald.dll
qmldbg_messagesd.dll
qmldbg_natived.dll
qmldbg_nativedebuggerd.dll
qmldbg_previewd.dll
qmldbg_profilerd.dll
qmldbg_quickprofilerd.dll
qmldbg_serverd.dll
qmldbg_tcpd.dll
<DIR> scenegraph
qsgd3d12backendd.dll
<DIR> styles
qwindowsvistastyled.dll
<DIR> translations
...
<DIR> virtualkeyboard
qtvirtualkeyboard_hanguld.dll
qtvirtualkeyboard_openwnnd.dll
qtvirtualkeyboard_pinyind.dll
qtvirtualkeyboard_tcimed.dll
qtvirtualkeyboard_thaid.dll
concrt140d.dll
d3dcompiler_47.dll
libEGLd.dll
libGLESv2d.dll
msvcp140d.dll
msvcp140d_atomic_wait.dll
msvcp140d_codecvt_ids.dll
msvcp140_1d.dll
msvcp140_2d.dll
qmltest.exe
qmltest.ilk
qmltest.pdb
Qt5Cored.dll
Qt5Guid.dll
Qt5Networkd.dll
Qt5Qmld.dll
Qt5Quickd.dll
Qt5Svgd.dll
Qt5Widgetsd.dll
vccorlib140d.dll
vcruntime140d.dll
I'm using Qt 5.15 open source. I built it and installed it on WIndows7. Any ideas? Thank you!
For one of our Windows app, we deploy over 1700 files. The directory structure looks roughly like this:
<DIR> MyQtApp_Bin_Dir
MyQtApp.exe
COPY C:\Qt\Qt5.15.6\5.15.6\msvc2019_64\bin\*.dll
COPY C:\Qt\Qt5.15.6\5.15.6\msvc2019_64\resources\*.*
COPY C:\Qt\Qt5.15.6\5.15.6\msvc2019_64\plugins\*
COPY VISUALSTUDIO_REDISTRIBUTABLES_HERE
<DIR> MyQtApp_Bin_Dir\qml
COPY C:\Qt\Qt5.15.6\5.15.6\msvc2019_64\qml\*
In the directory dump that you posted, the qml
folder appears to be absent. The content directly controls the import
statements that you are having issue with.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.