Avoid manually creating signals for every field in java #75
-
Hello, |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
QtJambi extracts all properties, invokables, slots and signals of a class at runtime. A signal is only detected if there actually is a signal field in Java code. It cannot be auto-generated. However, it does not make sense having a property notifiier signal without a signal field. I think you might want to call emit in the getter, don't you? public void setFoo(int foo){
this.foo = foo;
fooChanged.emit(foo);
}
public final Signal1<Integer> fooChanged = new Signal1<>(); |
Beta Was this translation helpful? Give feedback.
-
In fact, QProperty is the best solution to create fields that can be used in QML. However, according to my tests, QtJambi misses to set flag "scriptable" to properties defined with QProperty. Thus, QProperties cannot be used in QML up to now. The next update will fix this. Then you can simply define:
Item's text will change whenever If it is not possible or desirable to store the value in a QProperty, e.g. it is elsewhere computed, then you can use QComputedProperty instead:
Once the computed value changes you have to call |
Beta Was this translation helpful? Give feedback.
-
Since bufix patch release 6.3.4a (also 6.2.7a) it is possible to use QProperty-based object properties from within QML. |
Beta Was this translation helpful? Give feedback.
-
It is only the module qtjambi being versioned 6.2.7a, and here, only the java component. All other artifacts and native components remain version 6.2.7 and are fully compatible to 6.2.7a. |
Beta Was this translation helpful? Give feedback.
-
You can use QProperty in 6.2.7a to define bindable properties:
Make sure to declare property fields |
Beta Was this translation helpful? Give feedback.
QtJambi extracts all properties, invokables, slots and signals of a class at runtime. A signal is only detected if there actually is a signal field in Java code. It cannot be auto-generated. However, it does not make sense having a property notifiier signal without a signal field. I think you might want to call emit in the getter, don't you?