QGraphicsOpacityEffect 类

QGraphicsOpacityEffect class provides an opacity effect. 更多...

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

特性

公共函数

QGraphicsOpacityEffect (QObject * parent = Q_NULLPTR)
~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 )

额外继承成员

详细描述

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

默认情况下,不透明度是 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 = Q_NULLPTR)

构造新的 QGraphicsOpacityEffect instance. The parent 参数会被传递给 QGraphicsEffect 的构造函数。

QGraphicsOpacityEffect:: ~QGraphicsOpacityEffect ()

销毁效果。

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

重实现自 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.

注意: 通知程序信号对于特性 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 .