温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

QGraphicsOpacityEffect绘图处理介绍

发布时间:2020-06-20 21:40:20 来源:网络 阅读:4918 作者:WZM3558862 栏目:编程语言

QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsDropShadowEffect, 和 QGraphicsOpacityEffect.下面分别介绍它们。

QGraphicsBlurEffect
该类用应产生模糊效果,主要函数setBlurRadius(qreal blurRadius),用于控制图形元素的模糊度,数值越大越模糊。使用该类例子如下

QGraphicsBlurEffect *e0 = new QGraphicsBlurEffect(this);
e0->setBlurRadius(0.2);
item[0]->setGraphicsEffect(e1);//item[0] 为QGraphicsItem指针

QGraphicsColorizeEffect
该类提供了使用另外一种颜色对当前图形的一种着色功能。主要函数是setColor(QColor)和setStrength (qreal strength),指定了着色和着色强度。使用该类例子如下

QGraphicsColorizeEffect *e1 = new QGraphicsColorizeEffect(this);
e1->setColor(QColor(0,0,192));
item[1]->setGraphicsEffect(e1);

QGraphicsDropShadowEffect
该类提供了图形元素的阴影效果,用于增加立体感。主要设置函数有3个,setColor()用于设定阴影的颜色,setBlurRadius()用于设定阴影的模糊度,setOffset (qreal dx,qreal dy)用于设定在哪个方向产生阴影效果,如果dx为负数,则阴影在图形元素的左边。使用该类例子如下

QGraphicsDropShadowEffect *e2 = new QGraphicsDropShadowEffect(this);
e2->setOffset(8,8);
item[2]->setGraphicsEffect(e2);

QGraphicsOpacityEffect
该类用于图形元素的透明效果,主要函数是setOpacity(qreal opacity),用于设置透明度,参数值在0和1.0之间。也可以设置部分透明效果,需要调用的函数是setOpacityMask (QBrush mask)。使用该类例子如下

QGraphicsOpacityEffect *e3 = new QGraphicsOpacityEffect(this);
e3->setOpacity(0.7);
item[3]->setGraphicsEffect(e3);


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

qt gr
AI