QGraphicsOpacityEffect 類

QGraphicsOpacityEffect 類提供不透明度效果。 更多...

頭: #include <QGraphicsOpacityEffect>
qmake: QT += widgets
Since: Qt 4.6
繼承: QGraphicsEffect

該類在 Qt 4.6 引入。

特性

公共函數

QGraphicsOpacityEffect (QObject * parent = nullptr)
virtual ~QGraphicsOpacityEffect ()
qreal opacity () const
QBrush opacityMask () const

公共槽

void setOpacity (qreal opacity )
void setOpacityMask (const QBrush & mask )

信號

void opacityChanged (qreal opacity )
void opacityMaskChanged (const QBrush & mask )

重實現保護函數

virtual void draw (QPainter * painter ) override

詳細描述

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 () 函數。

默認情況下,不透明度是 0.7。

另請參閱 QGraphicsDropShadowEffect , QGraphicsBlurEffect ,和 QGraphicsColorizeEffect .

特性文檔編製

opacity : qreal

此特性保持效果的不透明度。

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.

默認情況下,不透明度是 0.7。

訪問函數:

qreal opacity () const
void setOpacity (qreal opacity )

通知程序信號:

void opacityChanged (qreal opacity )

另請參閱 setOpacityMask ().

opacityMask : QBrush

This property holds the opacity mask of the effect.

An opacity mask allows you apply opacity to portions of an element.

例如:

...
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.

訪問函數:

QBrush opacityMask () const
void setOpacityMask (const QBrush & mask )

通知程序信號:

void opacityMaskChanged (const QBrush & mask )

另請參閱 setOpacity ().

成員函數文檔編製

QGraphicsOpacityEffect:: QGraphicsOpacityEffect ( QObject * parent = nullptr)

Constructs a new QGraphicsOpacityEffect instance. The parent 參數會被傳遞給 QGraphicsEffect 的構造函數。

[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.

注意: 通知程序信號對於特性 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.

注意: 通知程序信號對於特性 opacityMask .

[虛擬] QGraphicsOpacityEffect:: ~QGraphicsOpacityEffect ()

銷毀效果。

[override virtual protected] void QGraphicsOpacityEffect:: draw ( QPainter * painter )

重實現: QGraphicsEffect::draw (QPainter *painter).