Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QQmlAnyBinding Class Reference

QQmlAnyBinding is an abstraction over the various bindings in QML. More...

#include <qqmlanybinding_p.h>

+ Collaboration diagram for QQmlAnyBinding:

Public Types

enum  InterceptorMode : bool { IgnoreInterceptors , RespectInterceptors }
 

Public Member Functions

constexpr QQmlAnyBinding () noexcept=default
 
 QQmlAnyBinding (std::nullptr_t)
 
void installOn (const QQmlProperty &target, InterceptorMode mode=IgnoreInterceptors)
 
bool hasError ()
 
QQmlAnyBindingoperator= (std::nullptr_t)
 Stores a null binding.
 
 operator bool () const
 
bool isAbstractPropertyBinding () const
 
bool isUntypedPropertyBinding () const
 
QUntypedPropertyBinding asUntypedPropertyBinding () const
 
QQmlAbstractBindingasAbstractBinding () const
 
void refresh ()
 
QQmlAnyBindingoperator= (QQmlAbstractBinding *binding)
 
QQmlAnyBindingoperator= (const QQmlAbstractBinding::Ptr &binding)
 
QQmlAnyBindingoperator= (QQmlAbstractBinding::Ptr &&binding)
 
QQmlAnyBindingoperator= (const QUntypedPropertyBinding &untypedBinding)
 
QQmlAnyBindingoperator= (QUntypedPropertyBinding &&untypedBinding)
 
 QQmlAnyBinding (QQmlAnyBinding &&other) noexcept
 
 QQmlAnyBinding (const QQmlAnyBinding &other) noexcept
 
void swap (QQmlAnyBinding &other) noexcept
 
QQmlAnyBindingoperator= (const QQmlAnyBinding &other) noexcept
 
 ~QQmlAnyBinding () noexcept
 

Static Public Member Functions

static QQmlAnyBinding ofProperty (const QQmlProperty &prop)
 
static QQmlAnyBinding ofProperty (QObject *object, QQmlPropertyIndex index)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.object must be non-null.
 
static QQmlAnyBinding takeFrom (const QQmlProperty &prop)
 Removes the binding from the property prop, and returns it as a QQmlAnyBinding if there was any.
 
static QQmlAnyBinding createFromFunction (const QQmlProperty &prop, QV4::Function *function, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, QV4::ExecutionContext *scope)
 
static QQmlAnyBinding createFromScriptString (const QQmlProperty &prop, const QQmlScriptString &script, QObject *obj, QQmlContext *ctxt)
 
static void removeBindingFrom (QQmlProperty &prop)
 
static QQmlAnyBinding createFromCodeString (const QQmlProperty &prop, const QString &code, QObject *obj, const QQmlRefPointer< QQmlContextData > &ctxt, const QString &url, quint16 lineNumber)
 
static QQmlAnyBinding createTranslationBinding (const QQmlProperty &prop, const QQmlRefPointer< QV4::ExecutableCompilationUnit > &compilationUnit, const QV4::CompiledData::Binding *translationBinding, QObject *scopeObject=nullptr, QQmlRefPointer< QQmlContextData > context={})
 

Friends

void swap (QQmlAnyBinding &lhs, QQmlAnyBinding &rhs) noexcept
 
bool operator== (const QQmlAnyBinding &p1, const QQmlAnyBinding &p2)
 
bool operator!= (const QQmlAnyBinding &p1, const QQmlAnyBinding &p2)
 

Detailed Description

QQmlAnyBinding is an abstraction over the various bindings in QML.

QQmlAnyBinding can store both classical bindings (derived from QQmlAbstractBinding) as well as new-style bindings (derived from QPropertyBindingPrivate). For both, it keeps a strong reference to them, and knows how to delete them in case the reference count becomes zero. In that sense it can be thought of as a union of QUntypedPropertyBinding and QQmlAbstractBinding::Ptr.

It also offers methods to create bindings (from QV4::Function, from translation bindings and from code strings). Moreover, it allows the retrieval, the removal and the installation of bindings on a QQmlProperty.

Note that the class intentionally does not allow construction from QUntypedProperty and QQmlAbstractBinding::Ptr. This is meant to catch code which doesn't handle bindable properties yet when porting existing code.

Definition at line 44 of file qqmlanybinding_p.h.

Member Enumeration Documentation

◆ InterceptorMode

Installs the binding referenced by this QQmlAnyBinding on the target. If mode is set to RespectInterceptors, interceptors are honored, otherwise writes and binding installation bypass them (the default). Preconditions:

Enumerator
IgnoreInterceptors 
RespectInterceptors 

Definition at line 226 of file qqmlanybinding_p.h.

Constructor & Destructor Documentation

◆ QQmlAnyBinding() [1/4]

constexpr QQmlAnyBinding::QQmlAnyBinding ( )
constexprdefaultnoexcept

◆ QQmlAnyBinding() [2/4]

QQmlAnyBinding::QQmlAnyBinding ( std::nullptr_t )
inline

Definition at line 48 of file qqmlanybinding_p.h.

◆ QQmlAnyBinding() [3/4]

QQmlAnyBinding::QQmlAnyBinding ( QQmlAnyBinding && other)
inlinenoexcept

Definition at line 421 of file qqmlanybinding_p.h.

◆ QQmlAnyBinding() [4/4]

QQmlAnyBinding::QQmlAnyBinding ( const QQmlAnyBinding & other)
inlinenoexcept

Definition at line 425 of file qqmlanybinding_p.h.

References other().

+ Here is the call graph for this function:

◆ ~QQmlAnyBinding()

QQmlAnyBinding::~QQmlAnyBinding ( )
inlinenoexcept

Definition at line 451 of file qqmlanybinding_p.h.

Referenced by QQmlBindEntryContent::destroy().

+ Here is the caller graph for this function:

Member Function Documentation

◆ asAbstractBinding()

QQmlAbstractBinding * QQmlAnyBinding::asAbstractBinding ( ) const
inline

Returns the stored QQmlAbstractBinding. If no such binding is currently stored, a null pointer is returned.

Definition at line 320 of file qqmlanybinding_p.h.

References QBiPointer< T, T2 >::asT1(), QBiPointer< T, T2 >::isNull(), and QBiPointer< T, T2 >::isT2().

Referenced by QQuickPropertyChanges::changeExpression(), hasError(), and installOn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ asUntypedPropertyBinding()

QUntypedPropertyBinding QQmlAnyBinding::asUntypedPropertyBinding ( ) const
inline

Returns the stored QPropertyBindingPrivate as a QUntypedPropertyBinding. If no such binding is currently stored, a null QUntypedPropertyBinding is returned.

Definition at line 307 of file qqmlanybinding_p.h.

References QBiPointer< T, T2 >::asT2(), QBiPointer< T, T2 >::isNull(), QBiPointer< T, T2 >::isT1(), and priv().

Referenced by hasError(), and installOn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFromCodeString()

static QQmlAnyBinding QQmlAnyBinding::createFromCodeString ( const QQmlProperty & prop,
const QString & code,
QObject * obj,
const QQmlRefPointer< QQmlContextData > & ctxt,
const QString & url,
quint16 lineNumber )
inlinestatic

Creates a binding for property prop from function. obj is the scope object which shall be used for the function and scope its QML scope. The binding is not installed on the property (but if a QQmlBinding is created, it has its target set to prop).

Definition at line 180 of file qqmlanybinding_p.h.

References QQmlBinding::create(), QQmlPropertyBinding::createFromCodeString(), QQmlPropertyPrivate::get(), QQmlProperty::isBindable(), QQmlProperty::object, and url.

Referenced by QQuickPropertyChanges::actions(), QQuickPropertyChanges::changeExpression(), and createBinding().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFromFunction()

static QQmlAnyBinding QQmlAnyBinding::createFromFunction ( const QQmlProperty & prop,
QV4::Function * function,
QObject * obj,
const QQmlRefPointer< QQmlContextData > & ctxt,
QV4::ExecutionContext * scope )
inlinestatic

Creates a binding for property prop from function. obj is the scope object which shall be used for the function and scope its QML scope. The binding is not installed on the property (but if a QQmlBinding is created, it has its target set to prop).

Definition at line 118 of file qqmlanybinding_p.h.

References QQmlBinding::create(), QQmlPropertyBinding::create(), QQmlPropertyPrivate::get(), QQmlProperty::isBindable(), and QQmlProperty::object.

Referenced by QQuickPropertyChanges::actions(), and createBinding().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createFromScriptString()

static QQmlAnyBinding QQmlAnyBinding::createFromScriptString ( const QQmlProperty & prop,
const QQmlScriptString & script,
QObject * obj,
QQmlContext * ctxt )
inlinestatic

Creates a binding for property prop from script. obj is the scope object which shall be used for the function and ctxt its QML scope. The binding is not installed on the property (but if a QQmlBinding is created, it has its target set to prop).

Definition at line 144 of file qqmlanybinding_p.h.

References QQmlBinding::create(), QQmlPropertyBinding::createFromScriptString(), QQmlPropertyPrivate::get(), QQmlProperty::isBindable(), and QQmlProperty::object.

Referenced by QQuickParentChange::actions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createTranslationBinding()

static QQmlAnyBinding QQmlAnyBinding::createTranslationBinding ( const QQmlProperty & prop,
const QQmlRefPointer< QV4::ExecutableCompilationUnit > & compilationUnit,
const QV4::CompiledData::Binding * translationBinding,
QObject * scopeObject = nullptr,
QQmlRefPointer< QQmlContextData > context = {} )
inlinestatic

Creates a translattion binding for prop from compilationUnit and transationBinding. obj is the context object, context the qml context.

Definition at line 202 of file qqmlanybinding_p.h.

Referenced by QQuickPropertyChanges::actions(), and createBinding().

+ Here is the caller graph for this function:

◆ hasError()

bool QQmlAnyBinding::hasError ( )
inline

Returns true if the binding is in an error state (e.g. binding loop), false otherwise.

Note
For ValueTypeProxyBindings, this methods will always return false

Definition at line 261 of file qqmlanybinding_p.h.

References asAbstractBinding(), asUntypedPropertyBinding(), QUntypedPropertyBinding::error(), hasError(), QPropertyBindingError::hasError(), isAbstractPropertyBinding(), and QQmlAbstractBinding::QmlBinding.

Referenced by hasError().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installOn()

void QQmlAnyBinding::installOn ( const QQmlProperty & target,
InterceptorMode mode = IgnoreInterceptors )
inline

Definition at line 231 of file qqmlanybinding_p.h.

References asAbstractBinding(), asUntypedPropertyBinding(), QMetaObject::BindableProperty, QQmlPropertyData::BypassInterceptor, QQmlPropertyData::DontRemoveBinding, QQmlPropertyPrivate::get(), IgnoreInterceptors, isAbstractPropertyBinding(), QBiPointer< T, T2 >::isNull(), QMetaObject::metacall(), QQmlPropertyPrivate::None, Q_ASSERT, QUntypedBindable::setBinding(), and QQmlPropertyPrivate::setBinding().

Referenced by QQuickPropertyChanges::changeExpression(), and QQDMIncubationTask::initializeRequiredProperties().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isAbstractPropertyBinding()

bool QQmlAnyBinding::isAbstractPropertyBinding ( ) const
inline

Returns true if a binding derived from QQmlAbstractPropertyBinding is stored. The binding migh still be null.

Definition at line 291 of file qqmlanybinding_p.h.

References QBiPointer< T, T2 >::isT1().

Referenced by QQuickStateAction::deleteFromBinding(), hasError(), and installOn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isUntypedPropertyBinding()

bool QQmlAnyBinding::isUntypedPropertyBinding ( ) const
inline

Returns true if a binding derived from QPropertyBindingPrivate is stored. The binding might still be null.

Definition at line 299 of file qqmlanybinding_p.h.

References QBiPointer< T, T2 >::isT2().

+ Here is the call graph for this function:

◆ ofProperty() [1/2]

static QQmlAnyBinding QQmlAnyBinding::ofProperty ( const QQmlProperty & prop)
inlinestatic

Returns the binding of the property prop as a QQmlAnyBinding. The binding continues to be active and set on the property. If there was no binding set, the returned QQmlAnyBinding is null.

Definition at line 56 of file qqmlanybinding_p.h.

References QMetaProperty::bindable(), QUntypedBindable::binding(), QQmlPropertyPrivate::binding(), QQmlProperty::isBindable(), QQmlProperty::object, and QQmlProperty::property().

Referenced by QQuickSimpleAction::QQuickSimpleAction(), QQuickState::apply(), QQmlBind::setObject(), and QQuickStateGroupPrivate::updateAutoState().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ofProperty() [2/2]

static QQmlAnyBinding QQmlAnyBinding::ofProperty ( QObject * object,
QQmlPropertyIndex index )
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.object must be non-null.

Definition at line 72 of file qqmlanybinding_p.h.

References QUntypedBindable::binding(), QQmlPropertyPrivate::binding(), QQmlData::ensurePropertyCache(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ operator bool()

QQmlAnyBinding::operator bool ( ) const
inline

Definition at line 282 of file qqmlanybinding_p.h.

References QBiPointer< T, T2 >::isNull().

+ Here is the call graph for this function:

◆ operator=() [1/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( const QQmlAbstractBinding::Ptr & binding)
inline

Stores the binding stored in binding and keeps a reference to it.

Definition at line 367 of file qqmlanybinding_p.h.

References QExplicitlySharedDataPointer< T >::data(), QQmlAbstractBinding::RefCount::ref(), and QQmlAbstractBinding::ref.

+ Here is the call graph for this function:

◆ operator=() [2/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( const QQmlAnyBinding & other)
inlinenoexcept

Definition at line 431 of file qqmlanybinding_p.h.

References other().

+ Here is the call graph for this function:

◆ operator=() [3/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( const QUntypedPropertyBinding & untypedBinding)
inline

Stores the binding stored in untypedBinding and keeps a reference to it.

Definition at line 394 of file qqmlanybinding_p.h.

References QPropertyBindingPrivate::get().

+ Here is the call graph for this function:

◆ operator=() [4/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( QQmlAbstractBinding * binding)
inline

Stores binding and keeps a reference to it.

Definition at line 353 of file qqmlanybinding_p.h.

References QQmlAbstractBinding::RefCount::ref(), and QQmlAbstractBinding::ref.

+ Here is the call graph for this function:

◆ operator=() [5/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( QQmlAbstractBinding::Ptr && binding)
inline

Stores binding's binding, taking ownership from binding.

Definition at line 381 of file qqmlanybinding_p.h.

◆ operator=() [6/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( QUntypedPropertyBinding && untypedBinding)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Stores the binding stored in untypedBinding, taking ownership from it.

Definition at line 410 of file qqmlanybinding_p.h.

References QPropertyBindingPrivate::get(), and ptr().

+ Here is the call graph for this function:

◆ operator=() [7/7]

QQmlAnyBinding & QQmlAnyBinding::operator= ( std::nullptr_t )
inline

Stores a null binding.

For purpose of classification, the null bindings is treated as a QQmlAbstractPropertyBindings.

Definition at line 276 of file qqmlanybinding_p.h.

◆ refresh()

void QQmlAnyBinding::refresh ( )
inline

Reevaluates the binding. If the binding was disabled, it gets enabled.

Definition at line 332 of file qqmlanybinding_p.h.

References QBiPointer< T, T2 >::asT1(), QBiPointer< T, T2 >::asT2(), QBiPointer< T, T2 >::isNull(), QBiPointer< T, T2 >::isT1(), and refresh().

Referenced by refresh().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeBindingFrom()

static void QQmlAnyBinding::removeBindingFrom ( QQmlProperty & prop)
inlinestatic

Removes the binding from prop if there is any.

Definition at line 165 of file qqmlanybinding_p.h.

References QMetaProperty::bindable(), QQmlProperty::isBindable(), QQmlProperty::object, QQmlProperty::property(), QQmlPropertyPrivate::removeBinding(), and QUntypedBindable::takeBinding().

Referenced by QQuickState::apply(), QQuickTransitionManager::cancel(), QQuickPropertyChanges::changeExpression(), QQmlBind::setDelayed(), and QQuickTransitionManager::transition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ swap()

void QQmlAnyBinding::swap ( QQmlAnyBinding & other)
inlinenoexcept

Definition at line 428 of file qqmlanybinding_p.h.

References other(), and QBiPointer< T, T2 >::swap().

+ Here is the call graph for this function:

◆ takeFrom()

static QQmlAnyBinding QQmlAnyBinding::takeFrom ( const QQmlProperty & prop)
inlinestatic

Removes the binding from the property prop, and returns it as a QQmlAnyBinding if there was any.

Otherwise returns a null QQmlAnyBinding.

Definition at line 94 of file qqmlanybinding_p.h.

References QMetaProperty::bindable(), QQmlPropertyPrivate::binding(), QQmlPropertyData::BypassInterceptor, QQmlPropertyData::DontRemoveBinding, QQmlProperty::isBindable(), QQmlProperty::object, QQmlProperty::property(), and QUntypedBindable::takeBinding().

Referenced by QQuickPropertyChanges::changeExpression().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const QQmlAnyBinding & p1,
const QQmlAnyBinding & p2 )
friend

Definition at line 446 of file qqmlanybinding_p.h.

◆ operator==

bool operator== ( const QQmlAnyBinding & p1,
const QQmlAnyBinding & p2 )
friend

Definition at line 441 of file qqmlanybinding_p.h.

◆ swap

void swap ( QQmlAnyBinding & lhs,
QQmlAnyBinding & rhs )
friend

Definition at line 429 of file qqmlanybinding_p.h.


The documentation for this class was generated from the following file: