[Qt-interest] Animated show/hide transitions for QFrame
Murphy, Sean M.
sean.murphy at gd-ais.com
Tue Jul 28 21:55:25 CEST 2009
> > 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.
In my example I kind of neglected the fact that you have other widgets
that are children of this frame, I have no idea what my example will do
in that case. So another idea I had was that when the user choose to
hide, you grab a pixmap of the frame and it's children using
QPixmap::grabWidget(), then hide the actual widget, replace it with the
pixmap, then shrink and fade the pixmap. When the user chooses to show
the widget again, you just reverse the process.
I'm pretty sure that's what the iPhone does for some of its transitions,
it takes a screenshot of the widgets and then scales the screenshot. To
the user it looks like the widgets themselves are being scaled.
Sean
More information about the Qt-interest-old
mailing list