[PySide] fading a widget on and off

Frank Rueter | OHUfx frank at ohufx.com
Tue Oct 22 20:33:23 CEST 2013


Ok, thanks Matt

On 23/10/13 07:19, Matthew Woehlke wrote:
> On 2013-10-22 01:29, Frank Rueter | OHUfx wrote:
>> once again I'm looking for a nudge in the right direction please:
>>
>> I'd like to be able to fade a widget on and off (based on the state of a
>> checkbox), and am wondering if I should write a custom paintEvent that
>> renders the widget as a pixmap at the respective transparency or if I
>> should look into QState and QStateMachine instead?! I have never used
>> states but it sounds like that will enable me to subsequently use
>> QtCore.QPropertyAnimation on a custom property (like opacity), is that
>> correct?
> So... I have a widget floating around that does something similar.
> However, the least broken way I was able to find to do this is to render
> the widget background, by telling the top level widget to render itself,
> clipped to the region of your widget, into a pixmap, then painting your
> widget as normal, and lastly overpainting the background pixmap at the
> desired opacity.
>
> If you render your own widget into a pixmap, IME it doesn't render the
> same as rendering on-screen (specifically I recall that text sub-pixel
> antialiasing isn't used).
>
> You can probably get away with doing the top level widget render only
> once, when you start the transition.
>
> That said, I wonder what setting CSS 'opacity' on a widget does... (not
> sure it is supported, however).
>
> You should be able to use QAnimation straight up to do the fade. I don't
> see how QStateMachine would be useful (other than as gratuitous
> overkill, maybe) here.
>




More information about the PySide mailing list