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. QML Application exit errors

QML Application exit errors

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qml c++ engineqml applicationqml app exit
2 Posts 2 Posters 885 Views 3 Watching
  • 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.
  • V Offline
    V Offline
    Vasilevs
    wrote on last edited by
    #1

    Greetings!
    I’ve stuck with problem creating QML application for Linux. Use Qt 5.11.
    The problem started, after I created utility class in QML for more convenient dynamical object creation.

    ComponentCreator.qml

        function createObject(path, parent)
        {
            let resultObject = undefined
    
            const component = Qt.createComponent(path, Component.PreferSynchronous, parent);
    
            switch (component.status)
            {
                case Component.Ready:
                    return component.createObject(parent);
                case Component.Error:
                    console.warn(qsTr("Component creation error:"), component.errorString());
                    return undefined
                default:
                    return undefined
            }
        }
    
        function createInputDataField(parent)
        {
            return createObject("qrc:/qml/Components/Input/InputDataField.qml", parent)
        }
    

    When close my QML app, I received this horrible stack trace output:
    9bfee5ff-5674-4e2e-b4c5-d85f8d7feae1-image.png alt text

    I thought, that problem could be connected with destruction of QQmlApplicationEngine. So I decided to wait until engine will be destroyed when closing app. It doesn’t really help, but console output became like this:
    db40615a-7f08-4a35-959a-ab71a59230b4-image.png
    This looks like parent destroyed, but created item - not.

    The thing is, when I place creation method in file, where object should be created, there are no more errors. I can only suggest, that there is a problem with contexts, but in what way - have no idea.

    I’ll be very grateful, if someone can give any ideas what causes that behavior.
    Thanks!

    ODБOïO 1 Reply Last reply
    0
    • V Vasilevs

      Greetings!
      I’ve stuck with problem creating QML application for Linux. Use Qt 5.11.
      The problem started, after I created utility class in QML for more convenient dynamical object creation.

      ComponentCreator.qml

          function createObject(path, parent)
          {
              let resultObject = undefined
      
              const component = Qt.createComponent(path, Component.PreferSynchronous, parent);
      
              switch (component.status)
              {
                  case Component.Ready:
                      return component.createObject(parent);
                  case Component.Error:
                      console.warn(qsTr("Component creation error:"), component.errorString());
                      return undefined
                  default:
                      return undefined
              }
          }
      
          function createInputDataField(parent)
          {
              return createObject("qrc:/qml/Components/Input/InputDataField.qml", parent)
          }
      

      When close my QML app, I received this horrible stack trace output:
      9bfee5ff-5674-4e2e-b4c5-d85f8d7feae1-image.png alt text

      I thought, that problem could be connected with destruction of QQmlApplicationEngine. So I decided to wait until engine will be destroyed when closing app. It doesn’t really help, but console output became like this:
      db40615a-7f08-4a35-959a-ab71a59230b4-image.png
      This looks like parent destroyed, but created item - not.

      The thing is, when I place creation method in file, where object should be created, there are no more errors. I can only suggest, that there is a problem with contexts, but in what way - have no idea.

      I’ll be very grateful, if someone can give any ideas what causes that behavior.
      Thanks!

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      hi
      @Vasilevs said in QML Application exit errors:

      I created utility class in QML for more convenient dynamical object creation.

          const component = Qt.createComponent(path, Component.PreferSynchronous, parent);
          switch (component.status)
          {
      

      try to connect a function to your component's statusChanged signal instead of checking the status just after the creation, see here https://doc.qt.io/qt-5/qtqml-javascript-dynamicobjectcreation.html

      @Vasilevs said in QML Application exit errors:

      This looks like parent destroyed, but created item - not.

      you can verify it with the debugger

      1 Reply Last reply
      0

      • Login

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