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. Calling a function from a new state
Forum Updated to NodeBB v4.3 + New Features

Calling a function from a new state

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 1.1k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    dstudentx
    wrote on last edited by
    #1

    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)@

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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")
      get_db(3);
      }
      @

      (Z(:^

      1 Reply Last reply
      0
      • J Offline
        J Offline
        JapieKrekel
        wrote on last edited by
        #3

        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") ...
        }
        @

        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