QGraphicsOpacityEffect Class
La classe QGraphicsOpacityEffect permet de créer un effet d'opacité. En savoir plus...
| En-tête : | #include <QGraphicsOpacityEffect> |
| CMake : | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
| qmake : | QT += widgets |
| Hérite de : | QGraphicsEffect |
Propriétés
- opacity : qreal
- opacityMask : QBrush
Fonctions publiques
| QGraphicsOpacityEffect(QObject *parent = nullptr) | |
| virtual | ~QGraphicsOpacityEffect() |
| qreal | opacity() const |
| QBrush | opacityMask() const |
Emplacements publics
| void | setOpacity(qreal opacity) |
| void | setOpacityMask(const QBrush &mask) |
Signaux
| void | opacityChanged(qreal opacity) |
| void | opacityMaskChanged(const QBrush &mask) |
Fonctions protégées réimplémentées
| virtual void | draw(QPainter *painter) override |
Description détaillée
Un effet d'opacité affiche la source avec une opacité. Cet effet est utile pour rendre la source semi-transparente, à l'instar d'une séquence de fondu entrant/sortant. L'opacité peut être modifiée à l'aide de la fonction setOpacity().
Par défaut, l'opacité est de 0,7.

Voir également QGraphicsDropShadowEffect, QGraphicsBlurEffect et QGraphicsColorizeEffect.
Documentation sur les propriétés
opacity : qreal
Cette propriété définit l'opacité de l'effet.
La valeur doit être comprise entre 0,0 et 1,0, où 0,0 correspond à une transparence totale et 1,0 à une opacité totale.
Par défaut, l'opacité est de 0,7.
Fonctions d'accès :
| qreal | opacity() const |
| void | setOpacity(qreal opacity) |
Signal de notification :
| void | opacityChanged(qreal opacity) |
Voir également setOpacityMask().
opacityMask : QBrush
Cette propriété contient le masque d'opacité de l'effet.
Un masque d'opacité vous permet d'appliquer une opacité à certaines parties d'un élément.
Par exemple :
//...
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);
//...Par défaut, il n'y a pas de masque d'opacité.
Fonctions d'accès :
| QBrush | opacityMask() const |
| void | setOpacityMask(const QBrush &mask) |
Signal de notification :
| void | opacityMaskChanged(const QBrush &mask) |
Voir aussi setOpacity().
Documentation des fonctions membres
QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent = nullptr)
Crée une nouvelle instance de `QGraphicsOpacityEffect`. Le paramètre ` parent ` est transmis au constructeur de ` QGraphicsEffect`.
[virtual noexcept] QGraphicsOpacityEffect::~QGraphicsOpacityEffect()
Annule l'effet.
[override virtual protected] void QGraphicsOpacityEffect::draw(QPainter *painter)
Réimplémente : QGraphicsEffect::draw(QPainter *painter).
[signal] void QGraphicsOpacityEffect::opacityChanged(qreal opacity)
Ce signal est émis chaque fois que l'opacité de l'effet change. Le paramètre opacity contient la nouvelle opacité de l'effet.
Remarque : signalde notification pour la propriété « opacity ».
[signal] void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)
Ce signal est émis chaque fois que le masque d'opacité de l'effet change. Le paramètre mask contient le nouveau masque d'opacité de l'effet.
Remarque : signalde notification pour la propriété 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.