Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 ()
bool isSticky () const
void setSticky (bool sticky=true)
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 45 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 239 of file qqmlanybinding_p.h.

Constructor & Destructor Documentation

◆ QQmlAnyBinding() [1/4]

QQmlAnyBinding::QQmlAnyBinding ( )
constexprdefaultnoexcept

◆ QQmlAnyBinding() [2/4]

QQmlAnyBinding::QQmlAnyBinding ( std::nullptr_t )
inline

Definition at line 49 of file qqmlanybinding_p.h.

◆ QQmlAnyBinding() [3/4]

QQmlAnyBinding::QQmlAnyBinding ( QQmlAnyBinding && other)
inlinenoexcept

Definition at line 453 of file qqmlanybinding_p.h.

References QQmlAnyBinding().

Referenced by QQmlAnyBinding().

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

◆ QQmlAnyBinding() [4/4]

QQmlAnyBinding::QQmlAnyBinding ( const QQmlAnyBinding & other)
inlinenoexcept

Definition at line 457 of file qqmlanybinding_p.h.

◆ ~QQmlAnyBinding()

QQmlAnyBinding::~QQmlAnyBinding ( )
inlinenoexcept

Definition at line 483 of file qqmlanybinding_p.h.

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 352 of file qqmlanybinding_p.h.

◆ 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 339 of file qqmlanybinding_p.h.

◆ createFromCodeString()

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 193 of file qqmlanybinding_p.h.

◆ createFromFunction()

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 131 of file qqmlanybinding_p.h.

◆ createFromScriptString()

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 157 of file qqmlanybinding_p.h.

◆ createTranslationBinding()

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 215 of file qqmlanybinding_p.h.

◆ 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 274 of file qqmlanybinding_p.h.

References isAbstractPropertyBinding().

Here is the call graph for this function:

◆ installOn()

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

Definition at line 244 of file qqmlanybinding_p.h.

References IgnoreInterceptors, and isAbstractPropertyBinding().

Here is the call 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 323 of file qqmlanybinding_p.h.

Referenced by hasError(), and installOn().

Here is the caller graph for this function:

◆ isSticky()

bool QQmlAnyBinding::isSticky ( ) const
inline

Definition at line 285 of file qqmlanybinding_p.h.

◆ 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 331 of file qqmlanybinding_p.h.

◆ ofProperty() [1/2]

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 57 of file qqmlanybinding_p.h.

◆ ofProperty() [2/2]

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 73 of file qqmlanybinding_p.h.

◆ operator bool()

QQmlAnyBinding::operator bool ( ) const
inline

Definition at line 314 of file qqmlanybinding_p.h.

◆ 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 399 of file qqmlanybinding_p.h.

◆ operator=() [2/7]

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

Definition at line 463 of file qqmlanybinding_p.h.

◆ 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 426 of file qqmlanybinding_p.h.

◆ operator=() [4/7]

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

Stores binding and keeps a reference to it.

Definition at line 385 of file qqmlanybinding_p.h.

◆ operator=() [5/7]

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

Stores binding's binding, taking ownership from binding.

Definition at line 413 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 442 of file qqmlanybinding_p.h.

◆ 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 308 of file qqmlanybinding_p.h.

◆ refresh()

void QQmlAnyBinding::refresh ( )
inline

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

Definition at line 364 of file qqmlanybinding_p.h.

◆ removeBindingFrom()

void QQmlAnyBinding::removeBindingFrom ( QQmlProperty & prop)
inlinestatic

Removes the binding from prop if there is any.

Definition at line 178 of file qqmlanybinding_p.h.

◆ setSticky()

void QQmlAnyBinding::setSticky ( bool sticky = true)
inline

Definition at line 294 of file qqmlanybinding_p.h.

◆ swap()

void QQmlAnyBinding::swap ( QQmlAnyBinding & other)
inlinenoexcept

Definition at line 460 of file qqmlanybinding_p.h.

◆ takeFrom()

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 107 of file qqmlanybinding_p.h.

◆ operator!=

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

Definition at line 478 of file qqmlanybinding_p.h.

◆ operator==

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

Definition at line 473 of file qqmlanybinding_p.h.

◆ swap

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

Definition at line 461 of file qqmlanybinding_p.h.


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