Please nominate your Qt Champions for 2021!

Global variable JS saved between runs with Settings

  • I have been working on a projet where I have used a StackView to switch between different pages. These pages are on different qml files. For one thing, I needed a variable accessible and editable to all the qml files/pages. I did a bit of research online and essentially created a separate JS file with .pragma library and the variable I needed. I then imported the file into each of my qml files and edited that variable. This was working fine. However, I ran into a problem. For a normal property defined inside the qml file, I can use a Settings object to save the value between runs. However, I cannot figure out how to do the same thing with my new variable in the javascript file without getting an error.
    Does anyone know any alternative ways for me to have a variable to use between qml files or a solution for me to save the value of that variable between runs?

Log in to reply