Graphics Effects
-
Hi
I am new to Qt and have started playing with graphics effect and cannot quite achieve what I want.
I have a an object of type QWidget that has a QButton as a child.
I want to apply a different effect to the QWidget and the button -m_effect1 = new QGraphicsOpacityEffect(); m_effect2 = new QGraphicsOpacityEffect(); m_effect1->setOpacity(1.0); m_effect2->setOpacity(1.0); ui.pushButton->setGraphicsEffect(m_effect2); ui.stackedWidget->setGraphicsEffect(m_effect1);
When I run the Qt complains the a paint device can only be painted by one painter at a time
Could anyone be kind enough to help me?
Thanks
Bob
-
this is not working when the 2 widgets are in parent-child relationship.
You can only achieve this when the 2 widgets have the same parent and you stack them above each other.
So if you depend on the parent-child relationship and can't break up your widgets this won't be possible.
-
Hi
Thanks for your reply
What do you mean byYou can only achieve this when the 2 widgets have the same parent and you stack them above each other.
Thanks
-
they both have the same parent and for example set the z-order (stacking) to make it look like the one is a child of the other.
You would ensure to layout the items by yourself though on every resize of the common parent.For z-order changing you can use QWidget methods: raise(), lower(), stackUnder()
-
Ok
Looks like I cant achieve what I need