QGraphicsOpacityEffect Class
The QGraphicsOpacityEffect class provides an opacity effect. More...
Header: | #include <QGraphicsOpacityEffect> |
qmake: | QT += widgets |
Since: | Qt 4.6 |
Inherits: | QGraphicsEffect |
Properties
- opacity : qreal
- opacityMask : QBrush
- 1 property inherited from QGraphicsEffect
- 1 property inherited from QObject
Public Functions
QGraphicsOpacityEffect(QObject *parent = nullptr) | |
virtual | ~QGraphicsOpacityEffect() |
qreal | opacity() const |
QBrush | opacityMask() const |
- 3 public functions inherited from QGraphicsEffect
- 31 public functions inherited from QObject
Public Slots
void | setOpacity(qreal opacity) |
void | setOpacityMask(const QBrush &mask) |
- 2 public slots inherited from QGraphicsEffect
- 1 public slot inherited from QObject
Signals
void | opacityChanged(qreal opacity) |
void | opacityMaskChanged(const QBrush &mask) |
- 1 signal inherited from QGraphicsEffect
- 2 signals inherited from QObject
Static Public Members
const QMetaObject | staticMetaObject |
- 9 static public members inherited from QObject
Reimplemented Protected Functions
virtual void | draw(QPainter *painter) override |
- 7 protected functions inherited from QGraphicsEffect
- 9 protected functions inherited from QObject
Detailed Description
The QGraphicsOpacityEffect class provides an opacity effect.
An opacity effect renders the source with an opacity. This effect is useful for making the source semi-transparent, similar to a fade-in/fade-out sequence. The opacity can be modified using the setOpacity() function.
By default, the opacity is 0.7.
See also QGraphicsDropShadowEffect, QGraphicsBlurEffect, and QGraphicsColorizeEffect.
Property Documentation
opacity : qreal
This property holds the opacity of the effect.
The value should be in the range of 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is fully opaque.
By default, the opacity is 0.7.
Access functions:
qreal | opacity() const |
void | setOpacity(qreal opacity) |
Notifier signal:
void | opacityChanged(qreal opacity) |
See also setOpacityMask().
opacityMask : QBrush
This property holds the opacity mask of the effect.
An opacity mask allows you apply opacity to portions of an element.
For example:
... 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); ...
There is no opacity mask by default.
Access functions:
QBrush | opacityMask() const |
void | setOpacityMask(const QBrush &mask) |
Notifier signal:
void | opacityMaskChanged(const QBrush &mask) |
See also setOpacity().
Member Function Documentation
QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent = nullptr)
Constructs a new QGraphicsOpacityEffect instance. The parent parameter is passed to QGraphicsEffect's constructor.
[virtual]
QGraphicsOpacityEffect::~QGraphicsOpacityEffect()
Destroys the effect.
[override virtual protected]
void QGraphicsOpacityEffect::draw(QPainter *painter)
Reimplemented from QGraphicsEffect::draw().
[signal]
void QGraphicsOpacityEffect::opacityChanged(qreal opacity)
This signal is emitted whenever the effect's opacity changes. The opacity parameter holds the effect's new opacity.
Note: Notifier signal for property opacity.
[signal]
void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)
This signal is emitted whenever the effect's opacity mask changes. The mask parameter holds the effect's new opacity mask.
Note: Notifier signal for property opacityMask.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.12/qgraphicsopacityeffect.html