このページでは

QGraphicsOpacityEffect Class

QGraphicsOpacityEffect クラスは、不透明度エフェクトを提供します。詳細...

ヘッダー: #include <QGraphicsOpacityEffect>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
継承元: QGraphicsEffect

プロパティ

パブリック関数

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

詳細な説明

不透明度エフェクトは、ソースを不透明度付きでレンダリングします。このエフェクトは、フェードイン/フェードアウトのシーケンスと同様に、ソースを半透明にするのに役立ちます。不透明度は、setOpacity() 関数を使用して変更できます。

デフォルトでは、不透明度は 0.7 です。

魚の画像に適用した不透明度効果

QGraphicsDropShadowEffect 、QGraphicsBlurEffect 、およびQGraphicsColorizeEffectも参照してください 。

プロパティのドキュメント

opacity : qreal

このプロパティは、エフェクトの不透明度を指定します。

値は 0.0 から 1.0 の範囲で指定する必要があります。0.0 は完全に透明、1.0 は完全に不透明を表します。

デフォルトでは、不透明度は 0.7 に設定されています。

アクセス関数:

qreal opacity() const
void setOpacity(qreal opacity)

通知シグナル:

void opacityChanged(qreal opacity)

関連項目: setOpacityMask()。

opacityMask : QBrush

このプロパティは、エフェクトの不透明度マスクを保持します。

不透明度マスクを使用すると、要素の一部に不透明度を適用することができます。

例:

//...
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);
//...

デフォルトでは不透明度マスクは設定されていません。

アクセス関数:

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

通知シグナル:

void opacityMaskChanged(const QBrush &mask)

関連項目: setOpacity()。

メンバ関数のドキュメント

QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent = nullptr)

新しい QGraphicsOpacityEffect インスタンスを作成します。parent パラメータは、QGraphicsEffect のコンストラクタに渡されます。

[virtual noexcept] QGraphicsOpacityEffect::~QGraphicsOpacityEffect()

その効果を解除します。

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

QGraphicsEffect::draw(QPainter *painter) を再実装します。

[signal] void QGraphicsOpacityEffect::opacityChanged(qreal opacity)

このシグナルは、エフェクトの不透明度が変更されるたびに発火します。opacity パラメータには、エフェクトの新しい不透明度が格納されます。

注: プロパティ `opacity` に関する通知 シグナルです。

[signal] void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)

このシグナルは、エフェクトの不透明度マスクが変更されるたびに発火します。mask パラメータには、エフェクトの新しい不透明度マスクが格納されます。

注: プロパティ `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.