[Qt-interest] Animated show/hide transitions for QFrame

Murphy, Sean M. sean.murphy at gd-ais.com
Tue Jul 28 21:36:15 CEST 2009


> I have a few QFrames laid out vertically. Within each QFrames are
> various unique widgets laid out in a grid. Between the QFrames I have
> placed buttons for showing and hiding them individually. When the user
> clicks one of the buttons, I call show() on the QFrame below it and it
> appears, moving the QFrames and buttons below it downward.
> 
> It works great, but it's so 1999.
> 
> It's 2009 so I want to animate it.
> 
> Rather than having each QFrame appear immediately on clicking the
> button, I want it to "grow" into place, optionally fading from
> transparent to opaque as it grows to its full size. This would be much
> like what happens when you drag QToolbars around and spots animate
open
> for you to drop them in.
> 
> Any ideas how to accomplish this tastefully? (i.e., reuse code from Qt
> as much as possible)

Here's a quick example I whipped up that grows/shrinks the frame.
Basically you just connect the button you're already using to a timer.
Every time the timer fires you adjust the size of the widget until it's
at the desired size.

I didn't try the fading part.  You might be able to get some hints about
doing that in the Analog Clock example
(http://doc.qtsoftware.com/4.5/widgets-analogclock.html), where they
paint the minute hand 75% opaque so that you can see the hour hand
through it.

Sean
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frameTransition.zip
Type: application/x-zip-compressed
Size: 3221 bytes
Desc: frameTransition.zip
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090728/d4b507d3/attachment.bin 


More information about the Qt-interest-old mailing list