Problems on using functions and saving to an offline storage

  • I using a lot of commands and functions on a single mousearea, but the problem is cant process them all, and when im trying to save a data when mousearea is clicked, and when i want to view the saved data, it resets to its original value,

    @MouseArea {
    id: ahome2status
    x: 4
    y: 549
    width: 99
    height: 75
    onClicked: {mainLoader.source = "status.qml";
    pimp.visible = false
    glass.visible = false
    ring.visible = false
    ginger.visible = false
    red.visible = false
    prince.visible = false
    leatherhatitem1.visible = false
    leafyitem1.visible = false
    goldmask.visible = false
    ahome2bath.visible = false
    ahome2feed.visible = false
    ahome2map.visible = false
    ahome2status.visible = false
    ahome2play.visible = false
    ahome2sleep.visible = false
    Storage.setSetting("setting", display.text)
    Storage.setSetting("setting2", display2.text)
    Storage.setSetting("setting3", display3.text)
    Storage.setSetting("setting4", display4.text)

    here is one of my mousearea, i think Qt cant process all my functions in a single click,
    I have 7 mouseareas with the same number of functions in my QML, is it advisable to use a lot of functions in a single mousearea click, and Loading another QML with a loader element??

    I think myQt Creator is having a hard time reading all my codes, and my javascript file,
    Any solutions??

  • One first thing that keep me suspiciuos is the mainLoader.source = "status.qml" statement. Is possible that this is a event that moves the program in another way so that you never set all or part of the others?

    Afaik, a betterpractice is - if the order is not essential - to manage the directe assignations before and timers reset after.

    Then try with a console.log("...") statement after every step to see if really all the assignements, resets etc are processed.

  • Moderators

    Also, if you find yourself replicating a lot of the same code in multiple places, you may want to consider moving it to a Javascript function() that you can call from multiple places.

  • As a code is simple and readable, as it is simple to isolate the issues.

  • yup, the mainloader.source will move you to another qml, and at the same time i want to implement the other functions on my mousearea onclicked,

    I tried moving all these commands to a javascript function but still, i experienced crash on my simulator,

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.