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. QguiApplication crashes due to Loader
Forum Updated to NodeBB v4.3 + New Features

QguiApplication crashes due to Loader

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 1.1k 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.
  • F Offline
    F Offline
    flowery
    wrote on last edited by
    #1

    I am facing an crash issue when dataModel refreshes (from backend using begin /end resetmodel ) after the openpage function gets called . Anyone please tell me what could be the issue with this loader assignation.If I add the loader inside delegate it is not crashing !!!!!
    Loader{
    id : loadView
    }

    Repeater{
    model: dataModel

    delegate: Item{
        function openPage{
         loadView.source="smeComp.qml"  
         loadView.item.model = dataModel
         loadView.item.delegate = Qt.createComponent("smeDelegate.qml")
                 
    }
    
        subDataModel{
            id: dataModel
        }
        Button{
            onClicked: openPage()
        }
    }
    

    }

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Loader loads only one qml file at a time. You are loading the multiple qml files using only loader. When the new file is loaded, old objects are deleted. Hence must be hitting the crash issue.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      F 1 Reply Last reply
      0
      • dheerendraD dheerendra

        Loader loads only one qml file at a time. You are loading the multiple qml files using only loader. When the new file is loaded, old objects are deleted. Hence must be hitting the crash issue.

        F Offline
        F Offline
        flowery
        wrote on last edited by
        #3

        @dheerendra New file will be loaded only when I click the button again right?. That means Open page function is getting called again .In that case it is not crashing.When the model assgined to repeater is reloaded ,the crash is happening.I suspect the subDataModel assigned to loader item gets deleted but the loader referring the same.Hence it is crashing.But I don't know how to confirm the same.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Number of delegate objects are same as number of elements in model. However you are using only one Loader. That will give issue.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • F Offline
            F Offline
            flowery
            wrote on last edited by
            #5

            Yes you are correct.On demand basis (button click event) only I am creating page.If I keep the Loader inside delegate ,the page is getting closed when model is refreshing .I want to keep the page open when model is refreshing.How to achieve the same

            1 Reply Last reply
            0
            • F Offline
              F Offline
              flowery
              wrote on last edited by
              #6

              found the root cause .creation context of Qt.createcomponent () inside delegates gets destroyed when model resets ,as per following rules.
              The actual creation context depends on how an object is created:

              If Qt.createComponent() is used, the creation context is the QQmlContext in which this method is called
              If Qt.createQmlObject() is called, the creation context is the context of the parent object passed to this method
              If a Component{} object is defined and createObject() or incubateObject() is called on that object, the creation context is the context in which the Component is defined.
              

              Solution is to move the creation context outside the delegate

              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