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
QPropertyAlias Class Reference

\inmodule QtCore More...

+ Collaboration diagram for QPropertyAlias:

Detailed Description

\inmodule QtCore

The QPropertyAlias class is a safe alias for a QProperty with same template parameter.

QPropertyAlias<T> wraps a pointer to a QProperty<T> and automatically invalidates itself when the QProperty<T> is destroyed. It forwards all method invocations to the wrapped property. For example:

QPropertyAlias<int> ageAlias(&age);
fullname.setBinding([&]() { return nameAlias.value() + " age: " + QString::number(ageAlias.value()); });
qDebug() << fullname.value(); // Prints "John age: 41"
*name = "Emma"; // Marks binding expression as dirty
qDebug() << fullname.value(); // Re-evaluates the binding expression and prints "Emma age: 41"
// Birthday is coming up
ageAlias.setValue(age.value() + 1); // Writes the age property through the alias
qDebug() << fullname.value(); // Re-evaluates the binding expression and prints "Emma age: 42"
delete name; // Leaves the alias in an invalid, but accessible state
nameAlias.setValue("Eve"); // Ignored: nameAlias carries a default-constructed QString now
ageAlias.setValue(92);
qDebug() << fullname.value(); // Re-evaluates the binding expression and prints " age: 92"
\inmodule QtCore
\inmodule QtCore
Definition qproperty.h:352
parameter_type value() const
Returns the value of the property.
Definition qproperty.h:387
QPropertyBinding< T > setBinding(const QPropertyBinding< T > &newBinding)
Associates the value of this property with the provided newBinding expression and returns the previou...
Definition qproperty.h:445
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:8133
EGLImageKHR EGLint * name
#define qDebug
[1]
Definition qlogging.h:165

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