QGraphicsBlurEffect on parent widget only

一笑奈何 提交于 2019-12-11 23:22:57

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/19309151/qgraphicsblureffect-on-parent-widget-only

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!