- All Implemented Interfaces:
QtObjectInterface
,Cloneable
public final class QBindable<T> extends QUntypedBindable
Java wrapper for Qt class QBindable
UseQBindable
to make a QObject.QProperty
field available as bindable QMetaProperty
.
Example:
public class MyObject extends QObject{
private final QProperty<QColor> color = new QProperty<>();
public QColor color(){
return color.value();
}
public void setColor(QColor color){
color.setValue(color);
}
public QBindable<QColor> bindableColor(){
return new QBindable<>(color);
}
}
To let QtJambi's metaobject system identify a method as bindable getter the method meets following signature and naming convention:
- returns
or a subtype ofQUntypedBindable
QUntypedBindable
- no parameters
- method name is "
bindableFoo
" for an available property "foo
" whereas "foo
" can be any name
If the bindable getter's name does not meet the upper naming convention
use the QtPropertyBindable
annotation instead and specify the
property's name by the annotation's QtPropertyBindable.name()
attribute.
Alternatively, it is possible to declare a
field QObject.QProperty
public
or by using the
annotation.
In this case, QBindable is supplied automatically:QtPropertyMember
public class MyObject extends QObject{
@QtPropertyMember
private final QProperty<QColor> color = new QProperty<>();
}
For primitive-typed implementations of QBindable
see:
-
Nested Class Summary
-
Constructor Summary
Constructors Constructor Description QBindable()
Creates a new invalidQBindable
.QBindable(QObject.QComputedProperty<T> property)
Creates a newQBindable
from provided property.QBindable(QObject.QProperty<T> property)
Creates a newQBindable
from provided property.QBindable(QProperty<T> property)
Creates a newQBindable
from provided property.QBindable(QPropertyAlias<T> property)
Creates a newQBindable
from provided property. -
Method Summary
Modifier and Type Method Description QPropertyBinding<T>
binding()
Returns the binding expression that is associated with the underlying property.static QBindable<@QtPrimitiveType Boolean>
fromProperty(QBooleanProperty property)
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Boolean>
fromProperty(QBooleanPropertyAlias property)
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Byte>
fromProperty(QByteProperty property)
Creates a newByte
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Byte>
fromProperty(QBytePropertyAlias property)
Creates a newByte
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Character>
fromProperty(QCharProperty property)
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Character>
fromProperty(QCharPropertyAlias property)
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Double>
fromProperty(QDoubleProperty property)
Creates a newDouble
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Double>
fromProperty(QDoublePropertyAlias property)
Creates a newDouble
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Float>
fromProperty(QFloatProperty property)
Creates a newFloat
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Float>
fromProperty(QFloatPropertyAlias property)
Creates a newFloat
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Integer>
fromProperty(QIntProperty property)
Creates a newInteger
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Integer>
fromProperty(QIntPropertyAlias property)
Creates a newInteger
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Long>
fromProperty(QLongProperty property)
Creates a newLong
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Long>
fromProperty(QLongPropertyAlias property)
Creates a newLong
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Boolean>
fromProperty(QObject.QBooleanProperty property)
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Byte>
fromProperty(QObject.QByteProperty property)
Creates a newByte
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Character>
fromProperty(QObject.QCharProperty property)
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Boolean>
fromProperty(QObject.QComputedBooleanProperty property)
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Byte>
fromProperty(QObject.QComputedByteProperty property)
Creates a newByte
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Character>
fromProperty(QObject.QComputedCharProperty property)
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Double>
fromProperty(QObject.QComputedDoubleProperty property)
Creates a newDouble
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Float>
fromProperty(QObject.QComputedFloatProperty property)
Creates a newFloat
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Integer>
fromProperty(QObject.QComputedIntProperty property)
Creates a newInteger
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Long>
fromProperty(QObject.QComputedLongProperty property)
Creates a newLong
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Short>
fromProperty(QObject.QComputedShortProperty property)
Creates a newShort
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Double>
fromProperty(QObject.QDoubleProperty property)
Creates a newDouble
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Float>
fromProperty(QObject.QFloatProperty property)
Creates a newFloat
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Integer>
fromProperty(QObject.QIntProperty property)
Creates a newInteger
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Long>
fromProperty(QObject.QLongProperty property)
Creates a newLong
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Short>
fromProperty(QObject.QShortProperty property)
Creates a newShort
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Short>
fromProperty(QShortProperty property)
Creates a newShort
-typed genericQBindable
from primitive-typed property.static QBindable<@QtPrimitiveType Short>
fromProperty(QShortPropertyAlias property)
Creates a newShort
-typed genericQBindable
from primitive-typed property.QPropertyBinding<T>
makeBinding()
Creates a binding to the underlying property.QPropertyBinding<T>
setBinding(QPropertyBinding<T> binding)
Associates the value of the underlying property with the providednewBinding
expression and returns the previously associated binding.QPropertyBinding<T>
setBinding(QtUtilities.Supplier<T> functor)
Associates the value of the underlying property with the providedfunctor
and returns the previously associated binding.void
setValue(T value)
Assigns newValue to the underlying property and removes the property's associated binding, if present.QPropertyBinding<T>
takeBinding()
Disassociates the binding expression from the underlying property and returns it.T
value()
Returns the value of the underlying property.Methods inherited from class io.qt.core.QUntypedBindable
clone, data, hasBinding, iface, isBindable, isReadOnly, isValid, observe, onValueChanged, setBinding, setData, setIface, subscribe
-
Constructor Details
-
QBindable
public QBindable()Creates a new invalidQBindable
. -
QBindable
Creates a newQBindable
from provided property.- Parameters:
property
-
-
QBindable
Creates a newQBindable
from provided property.- Parameters:
property
-
-
QBindable
Creates a newQBindable
from provided property.- Parameters:
property
-
-
QBindable
Creates a newQBindable
from provided property.- Parameters:
property
-
-
-
Method Details
-
fromProperty
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newByte
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newShort
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newInteger
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newLong
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newFloat
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newDouble
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newByte
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newShort
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newInteger
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newLong
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newFloat
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newDouble
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Boolean> fromProperty(QObject.QComputedBooleanProperty property)Creates a newBoolean
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Byte> fromProperty(QObject.QComputedByteProperty property)Creates a newByte
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Short> fromProperty(QObject.QComputedShortProperty property)Creates a newShort
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Integer> fromProperty(QObject.QComputedIntProperty property)Creates a newInteger
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Long> fromProperty(QObject.QComputedLongProperty property)Creates a newLong
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Float> fromProperty(QObject.QComputedFloatProperty property)Creates a newFloat
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Double> fromProperty(QObject.QComputedDoubleProperty property)Creates a newDouble
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
public static QBindable<@QtPrimitiveType Character> fromProperty(QObject.QComputedCharProperty property)Creates a newCharacter
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newBoolean
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newByte
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newShort
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newInteger
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newLong
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newFloat
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newDouble
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
fromProperty
Creates a newCharacter
-typed genericQBindable
from primitive-typed property.- Parameters:
property
-- Returns:
QBindable
-
makeBinding
Creates a binding to the underlying property.- Overrides:
makeBinding
in classQUntypedBindable
-
binding
Returns the binding expression that is associated with the underlying property. A default constructedQPropertyBinding
will be returned if no such association exists.- Overrides:
binding
in classQUntypedBindable
- Returns:
- binding
-
takeBinding
Disassociates the binding expression from the underlying property and returns it.
After calling this function, the value of the property will only change if you assign a new value to it, or when a new binding is set.
- Overrides:
takeBinding
in classQUntypedBindable
- Returns:
- the removed binding
-
setBinding
Associates the value of the underlying property with the provided
newBinding
expression and returns the previously associated binding.The binding's value type (
QUntypedPropertyBinding.valueMetaType()
) has to be equals to the property's value typeT
, otherwise the property remains unchanged.The first time the property value is read, the binding is evaluated. Whenever a dependency of the binding changes, the binding will be re-evaluated the next time the value of the underlying property is read.
- Parameters:
newBinding
-- Returns:
- oldBinding
-
setBinding
Associates the value of the underlying property with the provided
functor
and returns the previously associated binding.The first time the property value is read, the binding is evaluated by invoking
QtUtilities.Supplier.get()
offunctor
. Whenever a dependency of the binding changes, the binding will be re-evaluated the next time the value of the underlying property is read.- Parameters:
functor
-- Returns:
- oldBinding
-
value
Returns the value of the underlying property. This may evaluate a binding expression that is tied to the property, before returning the value.- Returns:
- value
-
setValue
Assigns newValue to the underlying property and removes the property's associated binding, if present.
- Parameters:
newValue
-
-