- All Implemented Interfaces:
QtObjectInterface
,Cloneable
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
Nested classes/interfaces inherited from class io.qt.QtObject
QtObject.QPrivateConstructor
-
Constructor Summary
ConstructorDescriptionCreates a new invalidQBindable
.Creates a new bindable from provided meta property of given object.Creates a new bindable from provided meta property of given object.Creates a newQBindable
from provided property.QBindable
(QPropertyAlias<T> property) Creates a newQBindable
from provided property.QBindable
(QObject.QComputedProperty<T> property) Creates a newQBindable
from provided property.QBindable
(QObject.QProperty<T> property) Creates a newQBindable
from provided property. -
Method Summary
Modifier and TypeMethodDescriptionbinding()
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.static <T> QBindable<T>
fromProperty
(QtUtilities.Supplier<T> propertyGetter) Creates a binding to the underlying property.setBinding
(QPropertyBinding<T> binding) Associates the value of the underlying property with the providednewBinding
expression and returns the previously associated binding.setBinding
(QtUtilities.Supplier<T> functor) Associates the value of the underlying property with the providedfunctor
and returns the previously associated binding.final void
Assigns newValue to the underlying property and removes the property's associated binding, if present.Disassociates the binding expression from the underlying property and returns it.final T
value()
Returns the value of the underlying property.Methods inherited from class io.qt.core.QUntypedBindable
addNotifier, clone, data, getData, getIface, hasBinding, iface, isBindable, isReadOnly, isValid, metaType, observe, onValueChanged, setBinding, setData, setIface, subscribe
Methods inherited from class io.qt.QtObject
dispose, equals, isDisposed
-
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
-
-
QBindable
Creates a new bindable from provided meta property of given object. If the type of the property is notshort
anIllegalArgumentException
is thrown.- Parameters:
object
-property
-
-
QBindable
public QBindable(QObject object, QMetaProperty property, Class<T> type, QMetaType ... instantiations) Creates a new bindable from provided meta property of given object. If the type of the property is notshort
anIllegalArgumentException
is thrown.- Parameters:
object
-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
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
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
-
fromProperty
-
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
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
-
-