Important: Please read the Qt Code of Conduct -

Calling a function from a new state

  • I have a sqlite database, I'm using a function to load the database.
    I can only get the database to show the contents in all the states not just specific states. Can't I just call the function in say state1

    here is how I'm calling the function.

    @Component.onCompleted: get_db(3)@

  • Moderators

    That depends when your component is being built (you are using onCompleted, after all!). You can try some JS code there:
    Component.onCompleted: {
    if (state == "state1")

  • And in addition to that, if you want to load different data you could use the onStateChanged in your item/component.
    onStateChanged: {
    if (state == "state1") get_db(3);
    else if (state == "state2") ...

Log in to reply