Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Importing QtQuick.XmlListModel causes simple QML/C++ app to crash
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 324 Views
  • 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 Offline
    D Offline
    deleted561
    wrote on last edited by deleted561
    #1

    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.HilkJ 1 Reply Last reply
    0
    • D 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.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      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


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

      D 1 Reply Last reply
      1
      • J.HilkJ J.Hilk

        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)

        D Offline
        D Offline
        deleted561
        wrote on last edited by
        #3

        @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
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved