QGraphicsOpacityEffect Class
Die Klasse „QGraphicsOpacityEffect“ bietet einen Deckkraft-Effekt. Mehr...
| Header: | #include <QGraphicsOpacityEffect> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake: | QT += widgets |
| Erbt von: | QGraphicsEffect |
Eigenschaften
- opacity : qreal
- opacityMask : QBrush
Öffentliche Funktionen
| QGraphicsOpacityEffect(QObject *parent = nullptr) | |
| virtual | ~QGraphicsOpacityEffect() |
| qreal | opacity() const |
| QBrush | opacityMask() const |
Öffentliche Slots
| void | setOpacity(qreal opacity) |
| void | setOpacityMask(const QBrush &mask) |
Signale
| void | opacityChanged(qreal opacity) |
| void | opacityMaskChanged(const QBrush &mask) |
Neu implementierte geschützte Funktionen
| virtual void | draw(QPainter *painter) override |
Ausführliche Beschreibung
Ein Opazitätseffekt rendert die Quelle mit einer Opazität. Dieser Effekt eignet sich, um die Quelle halbtransparent darzustellen, ähnlich einer Ein- und Ausblendsequenz. Die Opazität kann mithilfe der Funktion „ setOpacity()“ geändert werden.
Standardmäßig beträgt die Deckkraft 0,7.

Siehe auch „ QGraphicsDropShadowEffect “, „ QGraphicsBlurEffect “ und „ QGraphicsColorizeEffect “.
Eigenschaftsdokumentation
opacity : qreal
Diese Eigenschaft legt die Deckkraft des Effekts fest.
Der Wert sollte im Bereich von 0,0 bis 1,0 liegen, wobei 0,0 für vollständige Transparenz und 1,0 für vollständige Deckkraft steht.
Standardmäßig beträgt die Deckkraft 0,7.
Zugriffsfunktionen:
| qreal | opacity() const |
| void | setOpacity(qreal opacity) |
Notifier-Signal:
| void | opacityChanged(qreal opacity) |
Siehe auch ` setOpacityMask()`.
opacityMask : QBrush
Diese Eigenschaft enthält die Deckkraftmaske des Effekts.
Mit einer Deckkraftmaske können Sie auf bestimmte Bereiche eines Elements Deckkraft anwenden.
Beispiel:
//...
QLinearGradient alphaGradient(rect.topLeft(), rect.bottomLeft());
alphaGradient.setColorAt(0.0, Qt::transparent);
alphaGradient.setColorAt(0.5, Qt::black);
alphaGradient.setColorAt(1.0, Qt::transparent);
QGraphicsOpacityEffect *effect = new QGraphicsOpacityEffect;
effect->setOpacityMask(alphaGradient);
//...Standardmäßig ist keine Deckkraftmaske vorhanden.
Zugriffsfunktionen:
| QBrush | opacityMask() const |
| void | setOpacityMask(const QBrush &mask) |
Notifier-Signal:
| void | opacityMaskChanged(const QBrush &mask) |
Siehe auch ` setOpacity()`.
Dokumentation zu den Member-Funktionen
QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent = nullptr)
Erstellt eine neue Instanz von `QGraphicsOpacityEffect`. Der Parameter ` parent ` wird an den Konstruktor von ` QGraphicsEffect` übergeben.
[virtual noexcept] QGraphicsOpacityEffect::~QGraphicsOpacityEffect()
Hebt den Effekt auf.
[override virtual protected] void QGraphicsOpacityEffect::draw(QPainter *painter)
Implementiert: ` QGraphicsEffect::draw(QPainter *painter)`.
[signal] void QGraphicsOpacityEffect::opacityChanged(qreal opacity)
Dieses Signal wird immer dann ausgelöst, wenn sich die Deckkraft des Effekts ändert. Der Parameter „ opacity “ enthält die neue Deckkraft des Effekts.
Hinweis: Notifier -Signal für die Eigenschaft „ opacity “.
[signal] void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)
Dieses Signal wird immer dann ausgelöst, wenn sich die Deckkraftmaske des Effekts ändert. Der Parameter „ mask “ enthält die neue Deckkraftmaske des Effekts.
Hinweis: Notifier -Signal für die Eigenschaft „ opacityMask “.
© 2026 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.