QGraphicsBlurEffect只对父窗口部件 [英] QGraphicsBlurEffect on parent widget only

查看:511
本文介绍了QGraphicsBlurEffect只对父窗口部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试在另一个顶部显示一个小部件,并仅在父项上应用 QGraphicsBlurEffect

  MyWidget :: MyWidget(QWidget * parent):
QWidget(parent),
{
QGraphicsBlurEffect * effect = new QGraphicsBlurEffect(this);
parent-> setGraphicsEffect(effect);
}

但结果是两个部件都模糊。

$ b $



如何对父母只应用模糊效果?

解决方案

您最好的选择是打破父子关系。没有 QGraphicsEffects ItemIgnoresParentOpacity 的标志。



另一个解决方案是复制ItemIgnoresParentOpacity机制并实现它为QGraphicsEffect,但我不认为这是值得的麻烦。


I'm trying to show a widget on top of another and apply the QGraphicsBlurEffect only on the parent like this

MyWidget::MyWidget(QWidget* parent) :
QWidget(parent),
{
    QGraphicsBlurEffect* effect = new QGraphicsBlurEffect(this);
    parent->setGraphicsEffect(effect);
}

But the result is both widget are blur.

It seams like the effect is propagated to the childrens.

How can I apply the blur effect on the parent only?

解决方案

Your best option would be to break the parent-child relationship. There's no flags like QGraphicsItem's ItemIgnoresParentOpacity for QGraphicsEffects.

Another solution would be to copy the ItemIgnoresParentOpacity mechanism and implement it for QGraphicsEffect, but I don't think it's worth the trouble.

这篇关于QGraphicsBlurEffect只对父窗口部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆