QGraphicsBlurEffect只对父窗口部件 [英] QGraphicsBlurEffect on parent widget only
问题描述
我想尝试在另一个顶部显示一个小部件,并仅在父项上应用 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屋!