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. onStatusChanged not getting called always
QtWS25 Last Chance

onStatusChanged not getting called always

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlloaderonstatuschanged
1 Posts 1 Posters 336 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.
  • R Offline
    R Offline
    Rohith
    wrote on 6 May 2022, 09:54 last edited by Rohith 5 Jun 2022, 09:56
    #1

    Hello,

    I have a piece of code where i am trying to initialize the data and trying to load the respective qml file using Loader as a property.
    I am executing this in a device and this loader is getting called on ever boot up but it is getting called when ever i perform some operation after the boot up (let's say deleting one of the screen's from list of screens).
    Below is my code snippet
    ScreenInfo.qml

    QtObject{
    id:root
    function screenInfo() {
            // iterate the screenModel and stores the information in storeConfigGaugesObject
            var jsonString = JSON.stringify(storeConfigGaugesObject)
            root.jsonUpdated(jsonString)
        }
    function delete(index)
    {
      screen.remove(index)
      screeninfo()
    }
    }
    

    Data.qml

    QtObject{
    id:root
    property ModelData gaugesModel: ModelData {
            onJsonUpdated: {
                dataLoader.item.gCD1 = json
                console.error("====>ONJSONUPDATED::Json"+json)
                console.error("====>ONJSONUPDATED::gCD1"+dataLoader.item.gCD1)
            }
        }
    
        property Loader dataLoader: Loader{
                    source: "./Model.qml"
            onStatusChanged:  { /*The problem are is here, this part of code is only getting called on every bootup, when we are performing some operation like delete this part of code is not getting triggered*/
                console.error("dataLoaderStatus"+dataLoader.status)
                console.error("IsLoaderReady"+Loader.Ready)
                if (dataLoader.status === Loader.Ready) {
                    // populate the PTD
                    root.screenTypeDetails = dataLoader.item.screenTypeDetails
                    // populate the GTA
                    root.gaugeTypeArray = dataLoader.item.gaugeTypeArray
                    root.optionGauges = Qt.binding(function () { return dataLoader.item.optionGauges })
                    // populate the STA
                    for (var i = 0; i < screenTypeDetails.length; i++) {
                        screenTypeArray.push(screenTypeDetails[i].type)
                    }
                    gM.initData(dataLoader.item.gCD1)
                }
            }
        }
    }
    

    Model.qml

    QtObject{
    id:root
    function initScreenInfo(){
    //The received screen info in JSON format Data will be parsed and displayed here
    }
    }
    

    The Qt-5.15 is the version, any suggestion here are helpful.
    Thanks in advance !
    Regard's,
    Rohith.G

    1 Reply Last reply
    0

    1/1

    6 May 2022, 09:54

    • Login

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