Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Importing QtQuick.XmlListModel causes simple QML/C++ app to crash

    QML and Qt Quick
    2
    3
    156
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      deleted561 last edited by deleted561

      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:

      1. Compile the application in release 64-bit.
      2. Copy XmlListTest.exe file to an empty directory.
      3. 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
      4. 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:  }
      
      J.Hilk 1 Reply Last reply Reply Quote 0
      • J.Hilk
        J.Hilk Moderators @deleted561 last edited by

        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)

        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

        Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        D 1 Reply Last reply Reply Quote 1
        • D
          deleted561 @J.Hilk last edited by

          @J-Hilk Greetings and thank you! You fixed my problem.

          Odd ... I've been using windeployqt incorrectly, and only now did it bite me :-)

          1 Reply Last reply Reply Quote 1
          • First post
            Last post