Get the binding expression of the property
-
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 * 20When 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").
-
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 * 20When 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").
@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 -
@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@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. -
@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@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: x1using QMetaProperty does not help to distinguish between these properties