当前位置:网站首页>QT -- how to set shadow effect in QWidget
QT -- how to set shadow effect in QWidget
2022-07-02 08:50:00 【Code pirate captain】
Introduce
This is a tool to set up QWidget Control and its child control shadow effect class .
Parent class
Inherited from :QGraphicsEffect
attribute
blurRadius:qeal
Blur radius : have access to qreal blurRadius() const and void setBlurRadius(qreal blurRadius) Get and set the value of the current property , The default value is 1.
color:QColor
Set the shadow color : have access to QColor color() const and void setColor(const QColor &color) To set and get the value of the current property , The default value is (QColor(63, 63, 63, 180))
offset : QPointF
This attribute holds the shadow offset in pixels . By default , Lower right offset is 8 Pixels . The offset is given in the equipment coordinates , This means that it is not affected by proportion . have access to QPointF offset()const and void setOffset(const QPointF &ofs) To set and get the value of the current property .
xOffset : qreal
This attribute holds the shadow offset in pixels X.
yOffset : qreal
This attribute holds the shadow offset in pixels Y.
public inheritance
virtual QRectF boundingRectFor(const QRectF &rect) const override
Protection succession
virtual void draw(QPainter *painter) override
The signal
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);

Code demo
边栏推荐
猜你喜欢
随机推荐
Sqli labs level 12
[untitled]
Synchronize files using unison
Flex layout
KubeSphere 虚拟化 KSV 安装体验
Hcia - Application Layer
ARP及ARP欺骗
Tensorflow2 keras classification model
Minecraft module service opening
C # save web pages as pictures (using WebBrowser)
HCIA - data link layer
OpenShift构建镜像
Minecraft安装资源包
Oracle 相关统计
Oracle related statistics
OpenShift 容器平台社区版 OKD 4.10.0部署
HCIA - application layer
Kubedm deploys kubernetes v1.23.5 cluster
Routing foundation - dynamic routing
Linux二进制安装Oracle Database 19c








