OpacityMask QML Type | Qt Graphical Effects 5.15.19 (original) (raw)

Masks the source item with another item. More...

Import Statement: import QtGraphicalEffects 1.15
Since: QtGraphicalEffects 1.0
Inherits: Item

Properties

Detailed Description

Source MaskSource Effect applied

Note: This effect is available when running with OpenGL.

Example

The following example shows how to apply the effect.

import QtQuick 2.12 import QtGraphicalEffects 1.12

Item { width: 300 height: 300

[Image](qml-qtquick-image.html) {
    id: bug
    source: "images/bug.jpg"
    sourceSize: Qt.size(parent.width, parent.height)
    smooth: true
    visible: false
}

[Image](qml-qtquick-image.html) {
    id: mask
    source: "images/butterfly.png"
    sourceSize: Qt.size(parent.width, parent.height)
    smooth: true
    visible: false
}

[OpacityMask](qml-qtgraphicaleffects-opacitymask.html) {
    anchors.fill: bug
    source: bug
    maskSource: mask
}

}

Property Documentation

This property allows the effect output pixels to be cached in order to improve the rendering performance.

Every time the source or effect properties are changed, the pixels in the cache must be updated. Memory consumption is increased, because an extra buffer of memory is required for storing the effect output.

It is recommended to disable the cache when the source or the effect properties are animated.

By default, the property is set to false.

Note: It is not supported to let the effect include itself, for instance by setting maskSource to the effect's parent.

This property controls how the alpha values of the sourceMask will behave.

If this property is false, the resulting opacity is the source alpha multiplied with the mask alpha, As * Am.

If this property is true, the resulting opacity is the source alpha multiplied with the inverse of the mask alpha, As * (1 - Am).

The default is false.

This property was introduced in Qt 5.7.

This property defines the item that is going to be used as the mask. The mask item gets rendered into an intermediate pixel buffer and the alpha values from the result are used to determine the source item's pixels visibility in the display.

Original Mask Effect applied

This property defines the source item that is going to be masked.

Note: It is not supported to let the effect include itself, for instance by setting source to the effect's parent.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.