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. Get the binding expression of the property
Qt 6.11 is out! See what's new in the release blog

Get the binding expression of the property

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 2 Posters 604 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.
  • T Offline
    T Offline
    TurashviliAlik
    wrote on last edited by TurashviliAlik
    #1

    Is it possible, using C++ backend, to get the value of the expression used for binding at some property.
    Suppose I have a:

    property var test: x * 10 + y * 20
    

    When I call QMetaProperty::read and QQmlProperty::read, I get the already calculated value of the property. Is there any way to get a QJSValue that calculates this value? (in my example, I want to get "x * 10 + y * 20").

    GrecKoG 1 Reply Last reply
    0
    • T TurashviliAlik

      Is it possible, using C++ backend, to get the value of the expression used for binding at some property.
      Suppose I have a:

      property var test: x * 10 + y * 20
      

      When I call QMetaProperty::read and QQmlProperty::read, I get the already calculated value of the property. Is there any way to get a QJSValue that calculates this value? (in my example, I want to get "x * 10 + y * 20").

      GrecKoG Offline
      GrecKoG Offline
      GrecKo
      Qt Champions 2018
      wrote on last edited by
      #2

      @TurashviliAlik Why do you want it? Do you really want the string or way to evaluate it later?

      There's QQmlScriptString and QQmlExpression.

      Or you could have QJSValue and pass it a function instead:

      property var test: () => x * 10 + y * 20 // or (x, y) => x * 10 + y * 20 
      
      T 2 Replies Last reply
      0
      • GrecKoG GrecKo

        @TurashviliAlik Why do you want it? Do you really want the string or way to evaluate it later?

        There's QQmlScriptString and QQmlExpression.

        Or you could have QJSValue and pass it a function instead:

        property var test: () => x * 10 + y * 20 // or (x, y) => x * 10 + y * 20 
        
        T Offline
        T Offline
        TurashviliAlik
        wrote on last edited by
        #3

        @GrecKo I apologize for not responding for so long.
        I need this for my dynamic debugging module. Also, several times I have encountered a situation where I need to copy a bind expression from one property to another. That is, not to bind one property to another, but to copy the expression used in Qt.binding() for target property.

        1 Reply Last reply
        0
        • GrecKoG GrecKo

          @TurashviliAlik Why do you want it? Do you really want the string or way to evaluate it later?

          There's QQmlScriptString and QQmlExpression.

          Or you could have QJSValue and pass it a function instead:

          property var test: () => x * 10 + y * 20 // or (x, y) => x * 10 + y * 20 
          
          T Offline
          T Offline
          TurashviliAlik
          wrote on last edited by TurashviliAlik
          #4

          @GrecKo maybe you can suggest, is there any way to know if a property uses a binding to another property or not?

          property int x1: 100
          property int x2: x1
          

          using QMetaProperty does not help to distinguish between these properties

          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