Importing QtQuick.XmlListModel causes simple QML/C++ app to crash
-
I am using Qt 5.15.1 on Windows 7 with MSVC2019 (64-bit) configuration. The results are the same for the 32-bit configuration.
The source files for a simple app which replicates the problem are below. The steps to replicate are:
- Compile the application in release 64-bit.
- Copy XmlListTest.exe file to an empty directory.
- Open a cmd prompt, cd to the directory with XmlListTest.exe and run:
windeployqt --release --qmldir C:\Qt\5.15.1\msvc2019_64\qml .\XmlListTest.exe - Run XmlListTest.exe.
When I run XmlListTest.exe, either I get an error message (application was unable to start correctly) or there is no message and no window. In this second case, I have to stop the process using Task Manager.
If I remove line 4 (import QtQuick.XmlListModel 2.0) from window.qml and follow the steps above, the app runs as expected, displaying a small window.
The crash or no-window only happens when I run XmlListTest.exe outside of Qt Creator. When I run the app from inside Qt Creator, it executes as expected, displaying a small window.
I suspect that it might be a problem with windeployqt, but have no way of confirming this. I've tried running windeployqt with the --xml and --xmlpatterns options, but it did not change the results.
Does anyone know what the problem might be?
Thanks.
The XmlListTest.pro file is:
1: TEMPLATE = app 2: QT += qml quick xmlpatterns 3: CONFIG += c++11 4: SOURCES += main.cpp 5: RESOURCES += window.qml
The main.cpp file is:
1: #include <QGuiApplication> 2: #include <QQmlApplicationEngine> 3: 4: int main(int argc, char *argv[]) { 5: QGuiApplication app(argc, argv); 6: QQmlApplicationEngine engine; 7: engine.load(QUrl(QStringLiteral("qrc:/window.qml"))); 8: return app.exec(); 9: }
The window.qml file is:
1: import QtQuick 2.5 2: import QtQuick.Window 2.2 3: import QtQuick.Controls 1.4 4: import QtQuick.XmlListModel 2.0 5: 6: ApplicationWindow { 7: visible: true 8: width: 200 9: height: 100 10: title: qsTr("QML XML List Test") 11: }
-
hi @GrahamWilsonRMP said in Importing QtQuick.XmlListModel causes simple QML/C++ app to crash:
Does anyone know what the problem might be?
this:
--qmldir C:\Qt\5.15.1\msvc2019_64\qml
is the wrong qmldir. You passed the deployment tool the directory of your Qt installation.You have to give it the path to the directory of your QML files ( main.qml etc) the tool will than parse those files and fetch everything needed from the qt installation(the one that provided the windeployqt.exe)