java.lang.Object
io.qt.internal.QtJambiObject
io.qt.QtObject
io.qt.core.QUntypedPropertyData
io.qt.core.QObject.QComputedProperty<T>
- All Implemented Interfaces:
QtObjectInterface
- Enclosing class:
- QObject
public final class QObject.QComputedProperty<T> extends QUntypedPropertyData
The QComputedProperty
class is a template class for externally computed/stored values.
Create an instance of QComputedProperty
by providing a value supplier.
Example:
private final QComputedProperty<QColor> color = new QComputedProperty<>(this::computeOptimalColor);
The Java type QComputedProperty
corresponds to the C++ type QObjectComputedProperty
.
For primitive-typed implementations see:
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description QComputedProperty(QtUtilities.Supplier<T> getter)
Constructs a computed-value property whose type corresponds to the given value supplier. -
Method Summary
Modifier and Type Method Description boolean
hasBinding()
QPropertyChangeHandler
onValueChanged(Runnable f)
Registers the given functor f as a callback that shall be called whenever the value of the property changes.QPropertyChangeHandler
subscribe(Runnable f)
Subscribes the given functor f as a callback that is called immediately and whenever the value of the property changes in the future.T
value()
Returns the value of the property computed by the given getter.QMetaType
valueMetaType()
-
Constructor Details
-
QComputedProperty
Constructs a computed-value property whose type corresponds to the given value supplier.- Parameters:
getter
- supplying the computed value
-
-
Method Details
-
value
Returns the value of the property computed by the given getter.- Returns:
- value
-
valueMetaType
-
hasBinding
-
onValueChanged
Registers the given functor f as a callback that shall be called whenever the value of the property changes.
The returned property change handler object keeps track of the registration. As long as the change handler is alive i.e. as long as a reference to the
QPropertyChangeHandler
instance exists, the callback remains installed. When the garbage collection deletes the instance, the callback is de-registered.- Parameters:
f
-- Returns:
- property change handler
- See Also:
QPropertyChangeHandler
-
subscribe
Subscribes the given functor f as a callback that is called immediately and whenever the value of the property changes in the future.- Parameters:
f
-- Returns:
- property change handler
- See Also:
QPropertyChangeHandler
,onValueChanged(Runnable)
-