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. How to know if a property has a property binding?
Forum Updated to NodeBB v4.3 + New Features

How to know if a property has a property binding?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 901 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.
  • F Offline
    F Offline
    fxam
    wrote on last edited by
    #1

    Is there a way to know if a property has a property binding or is just a constant?

    For example, the following binds object.x to root.x:
    @
    Window {
    id: root
    x: object.x
    }
    @

    When a button is clicked, root.x holds a constant:
    @
    Button {
    onClicked: {
    root.x = 100
    }
    }
    @

    So how do we check if root.x is currently bound to object.x or is just a constant without binding?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      There is no direct way to check it. In the current case you are assigning the static value to root.x. In that case binding will be removed. Even if the object.x changes, root.x will remain constant. May be you can check for onXChanged signal handler see if it is called. If signal handler called means value is getting changed. These are simple work-around with side effects. ie. no full proof solution.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • F Offline
        F Offline
        fxam
        wrote on last edited by
        #3

        Thanks. I think manually setting a bool flag when the code changes between binding and constant will do too.

        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