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 (const 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 47 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 241 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 51 of file qqmlanybinding_p.h.

◆ QQmlAnyBinding() [3/4]

QQmlAnyBinding::QQmlAnyBinding ( QQmlAnyBinding && other)
inlinenoexcept

Definition at line 469 of file qqmlanybinding_p.h.

◆ QQmlAnyBinding() [4/4]

QQmlAnyBinding::QQmlAnyBinding ( const QQmlAnyBinding & other)
inlinenoexcept

Definition at line 473 of file qqmlanybinding_p.h.

◆ ~QQmlAnyBinding()

QQmlAnyBinding::~QQmlAnyBinding ( )
inlinenoexcept

Definition at line 499 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 368 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 355 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 195 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 133 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 159 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 217 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 290 of file qqmlanybinding_p.h.

◆ installOn()

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

Definition at line 246 of file qqmlanybinding_p.h.

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

◆ isSticky()

bool QQmlAnyBinding::isSticky ( ) const
inline

Definition at line 301 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 347 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 59 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 75 of file qqmlanybinding_p.h.

◆ operator bool()

QQmlAnyBinding::operator bool ( ) const
inline

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

◆ operator=() [2/7]

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

Definition at line 479 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 442 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 401 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 429 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 458 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 324 of file qqmlanybinding_p.h.

◆ refresh()

void QQmlAnyBinding::refresh ( )
inline

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

Definition at line 380 of file qqmlanybinding_p.h.

◆ removeBindingFrom()

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

Removes the binding from prop if there is any.

Definition at line 180 of file qqmlanybinding_p.h.

◆ setSticky()

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

Definition at line 310 of file qqmlanybinding_p.h.

◆ swap()

void QQmlAnyBinding::swap ( QQmlAnyBinding & other)
inlinenoexcept

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

◆ operator!=

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

Definition at line 494 of file qqmlanybinding_p.h.

◆ operator==

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

Definition at line 489 of file qqmlanybinding_p.h.

◆ swap

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

Definition at line 477 of file qqmlanybinding_p.h.


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