当前位置:网站首页>Qt——如何在QWidget中设置阴影效果
Qt——如何在QWidget中设置阴影效果
2022-07-02 06:30:00 【代码海贼团船长】
介绍
这是一个用来设置QWidget控件及其子控件阴影效果的类。
父类
继承自:QGraphicsEffect
属性
blurRadius:qeal
模糊半径:可以使用 qreal blurRadius() const 和void setBlurRadius(qreal blurRadius)获取和设置当前属性的值,默认值是1。
color:QColor
设置阴影颜色:可以使用QColor color() const和void setColor(const QColor &color)来设置和获取当前属性的值,默认值是(QColor(63, 63, 63, 180))
offset : QPointF
这个属性保存以像素为单位的阴影偏移量。默认情况下,向右下方偏移量为8像素。偏移量是在设备坐标中给出的,这意味着它不受比例的影响。可以使用QPointF offset()const和void setOffset(const QPointF &ofs)来设置和获取当前属性的值。
xOffset : qreal
这个属性保存以像素为单位的阴影偏移量X。
yOffset : qreal
这个属性保存以像素为单位的阴影偏移量Y。
公有继承
virtual QRectF boundingRectFor(const QRectF &rect) const override
保护继承
virtual void draw(QPainter *painter) override
信号
void blurRadiusChanged(qreal blurRadius)
void colorChanged(const QColor &color)
void offsetChanged(const QPointF &offset)
QGraphicsDropShadowEffect*mpGraphicsDropShadowEffect= new QGraphicsDropShadowEffect(this);
mpGraphicsDropShadowEffect->setColor(QColor(100,100,100,100));
mpGraphicsDropShadowEffect->setBlurRadius(2);
mpGraphicsDropShadowEffect->setOffset(2.5);
ui->label->setGraphicsEffect(mpGraphicsDropShadowEffect);
代码demo
边栏推荐
猜你喜欢
[untitled]
When a custom exception encounters reflection
Use the kaggle training model and download your own training model
Data asset management function
OpenFeign 简单使用
类和对象(类和类的实例化,this,static关键字,封装)
Minecraft安装资源包
Minecraft模组服开服
Tcp/ip - transport layer
C language custom type enumeration, Union (clever use of enumeration, calculation of union size)
随机推荐
kubernetes部署loki日志系统
Minecraft群組服開服
k8s入门:Helm 构建 MySQL
ICMP Protocol
Use the numbers 5, 5, 5, 1 to perform four operations. Each number should be used only once, and the operation result value is required to be 24
Sqli labs (post type injection)
HCIA - data link layer
Programmer training, crazy job hunting, overtime ridiculed by colleagues deserve it
D interface and domain problems
Googlenet network explanation and model building
Sqli labs level 1
【无标题】
gocv边界填充
Use Wireshark to grab TCP three handshakes
HackTheBox-Gunship
Realize bidirectional linked list (with puppet node)
群辉 NAS 配置 iSCSI 存储
Linked list classic interview questions (reverse the linked list, middle node, penultimate node, merge and split the linked list, and delete duplicate nodes)
Smart agriculture solutions smart agriculture system development
Linux安装Oracle Database 19c