- class QQuickAttachedPropertyPropagator¶
The
QQuickAttachedPropertyPropagator
class provides a way to propagate attached properties. More…Synopsis¶
Methods¶
def
__init__()
def
attachedParent()
def
initialize()
Virtual methods¶
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description¶
In QML, it is possible to attach properties and signal handlers to objects. Providing Attached Properties goes into more detail about how to expose your own C++ attached types.
QQuickAttachedPropertyPropagator
provides an API to propagate attached properties from a parent object to its children, similar to font and palette propagation. It supports propagation through items, popups , and windows.If propagation of properties is not important, consider using a C++ or QML singleton instead, as it is better suited for that use case, and is more efficient in that it only requires one QObject.
To use
QQuickAttachedPropertyPropagator
:Derive from it
Call
initialize()
in the constructorDefine set/inherit/propagate/reset functions for each property as needed
Reimplement
attachedParentChange()
to handle property inheritanceImplement a static
qmlAttachedProperties
function and declare the type as an attached QML type with QML_ELEMENT and QML_ATTACHED, as detailed in Providing Attached Properties
For an example that demonstrates this in depth, see Qt Quick Controls - Attached Style Properties Example .
See also
Constructs a
QQuickAttachedPropertyPropagator
with the givenparent
.The
parent
will be used to find this object’sattached parent
.Derived classes should call
initialize()
in their constructor.- attachedChildren()¶
- Return type:
.list of QQuickAttachedPropertyPropagator
This function returns the attached children of this attached object.
The attached children are used when propagating property values:
- attachedParent()¶
- Return type:
This function returns the attached parent of this attached object.
The attached parent is used when inheriting property values:
- attachedParentChange(newParent, oldParent)¶
- Parameters:
newParent –
QQuickAttachedPropertyPropagator
oldParent –
QQuickAttachedPropertyPropagator
This function is called whenever the attached parent of this
QQuickAttachedPropertyPropagator
changes fromoldParent
tonewParent
.Subclasses should reimplement this function to inherit attached properties from
newParent
.- initialize()¶
Finds and sets the attached parent for this attached object, and then does the same for its children. This must be called upon construction of the attached object in order for propagation to work.
It can be useful to read global/default values before calling this function. For example, before calling
initialize()
, the Imagine style checks a static “globalsInitialized” flag to see if it should read default values from QSettings. The values from that file form the basis for any attached property values that have not been explicitly set.