PDA

View Full Version : Animation effect of gif in QPushButton



santosh.kumar
1st March 2011, 09:52
Hi,

I have an animated (attached)gif file. I have set this to a PushButton
icon like in the following :-


QPushButton* button = new QPushButton(this);
button->setIcon(QIcon((":/images/1.gif")));
button->setIconSize(QSize(128,128));
button->setFlat(true);


But I am not able to see the animation effect in the GUI.

Please tell me some body to see animation effect.

Thanks
Santosh

high_flyer
1st March 2011, 11:28
Have a look QMovie.

santosh.kumar
3rd March 2011, 07:33
Have a look QMovie.

But QMovie will work for QLabel not for QPushButton.

I want to set the .gif as icon on QPushButton and it should be animated.

Thanks
Santosh

unit
3rd March 2011, 07:58
create new class-widget from QPushButton

and reimp paintEvent(QPaintEvent *). Src code of qlabel will help you.

high_flyer
3rd March 2011, 12:01
But QMovie will work for QLabel not for QPushButton.

I want to set the .gif as icon on QPushButton and it should be animated.

Well, then, subclass QPushButton and add a QLabel member to it.
Problem solved.

santosh.kumar
3rd March 2011, 12:07
Well, then, subclass QPushButton and add a QLabel member to it.
Problem solved.

Can u give small sample code for this..

Thanks
Santosh

high_flyer
3rd March 2011, 12:14
I'll tell you what - you try first.
If you get in to trouble, post your code, and your question, and I'll help.
Ok?