QGraphicsDropShadowEffect Class
QGraphicsDropShadowEffect 类提供了一种阴影效果。更多
头文件: | #include <QGraphicsDropShadowEffect> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Widgets) target_link_libraries(mytarget PRIVATE Qt6::Widgets) |
qmake: | QT += widgets |
继承: | QGraphicsEffect |
属性
|
公共函数
QGraphicsDropShadowEffect(QObject *parent = nullptr) | |
virtual | ~QGraphicsDropShadowEffect() |
qreal | blurRadius() const |
QColor | color() const |
QPointF | offset() const |
qreal | xOffset() const |
qreal | yOffset() const |
重新实现的公共函数
virtual QRectF | boundingRectFor(const QRectF &rect) const override |
公共插槽
void | setBlurRadius(qreal blurRadius) |
void | setColor(const QColor &color) |
void | setOffset(const QPointF &ofs) |
void | setOffset(qreal d) |
void | setOffset(qreal dx, qreal dy) |
void | setXOffset(qreal dx) |
void | setYOffset(qreal dy) |
信号
void | blurRadiusChanged(qreal blurRadius) |
void | colorChanged(const QColor &color) |
void | offsetChanged(const QPointF &offset) |
重新实现的受保护函数
virtual void | draw(QPainter *painter) override |
详细说明
阴影效果为源图像添加阴影。可以使用setColor() 函数修改阴影的颜色。使用setOffset() 函数可以修改阴影偏移量,使用setBlurRadius() 函数可以更改阴影的模糊半径。
默认情况下,阴影为半透明深灰色(QColor(63, 63, 63, 180)),半径为 1,向右下方偏移 8 像素。阴影偏移量以设备坐标指定。
另请参阅 QGraphicsBlurEffect,QGraphicsColorizeEffect, 和QGraphicsOpacityEffect 。
属性文档
blurRadius : qreal
该属性表示阴影的模糊半径(以像素为单位)。
半径越小,阴影越清晰,半径越大,阴影越模糊。
默认情况下,模糊半径为 1 像素。
访问功能:
qreal | blurRadius() const |
void | setBlurRadius(qreal blurRadius) |
通知信号:
void | blurRadiusChanged(qreal blurRadius) |
color : QColor
该属性用于保存阴影的颜色。
默认情况下,阴影颜色为半透明的深灰色 (QColor(63, 63, 63, 180))。
访问功能:
QColor | color() const |
void | setColor(const QColor &color) |
Notifier 信号:
void | colorChanged(const QColor &color) |
另请参见 offset() 和blurRadius()。
offset : QPointF
此属性以像素为单位保存阴影偏移量。
默认情况下,偏移量为右下方 8 个像素。
偏移量以设备坐标为单位,因此不受缩放比例的影响。
访问功能:
QPointF | offset() const |
void | setOffset(const QPointF &ofs) |
void | setOffset(qreal dx, qreal dy) |
void | setOffset(qreal d) |
Notifier 信号:
void | offsetChanged(const QPointF &offset) |
另请参见 xOffset()、yOffset()、blurRadius() 和color()。
xOffset : qreal
该属性以像素为单位保存水平阴影偏移量。
默认情况下,水平阴影偏移量为 8 像素。
访问功能:
qreal | xOffset() const |
void | setXOffset(qreal dx) |
Notifier 信号:
void | offsetChanged(const QPointF &offset) |
yOffset : qreal
该属性以像素为单位保存垂直阴影偏移量。
默认情况下,垂直阴影偏移量为 8 像素。
访问功能:
qreal | yOffset() const |
void | setYOffset(qreal dy) |
Notifier 信号:
void | offsetChanged(const QPointF &offset) |
成员函数文档
QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent = nullptr)
构造一个新的 QGraphicsDropShadowEffect 实例。parent 参数传递给QGraphicsEffect 的构造函数。
[virtual noexcept]
QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect()
破坏效果。
[signal]
void QGraphicsDropShadowEffect::blurRadiusChanged(qreal blurRadius)
每当特效的模糊半径发生变化时,就会发出该信号。blurRadius 参数包含效果的新模糊半径。
注: 属性blurRadius 的通知信号。
[override virtual]
QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const
重实现:QGraphicsEffect::boundingRectFor(const QRectF &rect) const.
[signal]
void QGraphicsDropShadowEffect::colorChanged(const QColor &color)
每当特效的颜色发生变化时,就会发出该信号。color 参数包含效果的新颜色。
注: 属性color 的通知信号。
[override virtual protected]
void QGraphicsDropShadowEffect::draw(QPainter *painter)
重实现:QGraphicsEffect::draw(QPainter *painter).
[signal]
void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset)
每当特效的阴影偏移发生变化时,就会发出该信号。offset 参数包含效果的新阴影偏移量。
© 2025 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.