Closed mchistovib closed 1 year ago
This is not a bug. As stated here the property is automatically detected and the property name is cut if the field name ends with Property
. Here, class Model has two properties computed
and computedProperty2
. Thus, QML binding "Test text: " + passedModel.computedProperty
refers to non-existing property.
"In QObject-derived classes, public final fields are considered to be constant (read-only) properties. Additionally, a final QProperty<...> fooProperty
field is automatically considered to be property foo
. You don't need getter, setter and bindable."
When having unexpected Java <-> QML behavior is is worth printing property and method signatures:
QMetaObject.forType(Model.class).properties().forEach(p->System.out.println(p.typeName()+" "+p.name()));
QMetaObject.forType(Model.class).methods().forEach(m->System.out.println(m.typeName()+" "+m.cppMethodSignature()));
To avoid name reduction use @QtPropertyMember(name="computedProperty")
.
There is still a bug that leads to crash though, closing until there is a clear way to reproduce it..
Describe the bug We have found a bug when using lambda created inside a function for computable property - it never gets real data in it. For one of our colleagues that led to a crash since the code likely didn't expect the undefined value to be there forever. Computed property fails to load data from lambda created in function call, it should work the same as with lambda create on class level
To Reproduce Steps to reproduce the behavior:
Test files: Main.java
main.qml
Expected behavior Both computed properties are returning actual data
Screenshots
System (please complete the following information):