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. Execute function when value of variable changes.

Execute function when value of variable changes.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 2.0k 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.
  • V Offline
    V Offline
    viktorp
    wrote on last edited by
    #1

    Hello, is there a way in QML to execute a function when the value of a variable changes?

    ODБOïO 1 Reply Last reply
    0
    • V viktorp

      Hello, is there a way in QML to execute a function when the value of a variable changes?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi @viktorp

      Yes it is. That is a fundamental concept.

      every property has its onPropertyNameChanged handler.

      every property you will declare + all the default properties of QML Types (Item/Rectangle/Image/Button...) work like that.

      property int myVar : 5
      onMyVarChanged : { console.log(myVar) }
      
      Rectangle{
         height : 50
        onHeightChanged : { /*call function*/}
      }
      
      1 Reply Last reply
      5
      • V Offline
        V Offline
        viktorp
        wrote on last edited by
        #3

        Thank you very much! I missed that one :)

        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