Results 1 to 7 of 7

Thread: Animation effect of gif in QPushButton

  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Animation effect of gif in QPushButton

    Hi,

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

    Qt Code:
    1. QPushButton* button = new QPushButton(this);
    2. button->setIcon(QIcon((":/images/1.gif")));
    3. button->setIconSize(QSize(128,128));
    4. button->setFlat(true);
    To copy to clipboard, switch view to plain text mode 


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

    Please tell me some body to see animation effect.

    Thanks
    Santosh
    Last edited by high_flyer; 1st March 2011 at 10:26.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Animation effect of gif in QPushButton

    Have a look QMovie.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Animation effect of gif in QPushButton

    Quote Originally Posted by high_flyer View Post
    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

  4. #4
    Join Date
    Oct 2010
    Location
    Belarus
    Posts
    71
    Thanks
    1
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Windows Maemo/MeeGo

    Default Re: Animation effect of gif in QPushButton

    create new class-widget from QPushButton

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

  5. #5
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Animation effect of gif in QPushButton

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  6. #6
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Animation effect of gif in QPushButton

    Quote Originally Posted by high_flyer View Post
    Well, then, subclass QPushButton and add a QLabel member to it.
    Problem solved.
    Can u give small sample code for this..

    Thanks
    Santosh

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Animation effect of gif in QPushButton

    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?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Removing pressed effect from a QPushButton
    By Luc4 in forum Qt Programming
    Replies: 3
    Last Post: 14th August 2010, 11:43
  2. 3D Effect
    By andzoff in forum Qt Programming
    Replies: 2
    Last Post: 15th March 2010, 11:52
  3. Replies: 0
    Last Post: 22nd February 2010, 09:30
  4. QPushButton fade effect without animation
    By Kostanev in forum Qt Programming
    Replies: 11
    Last Post: 12th November 2008, 09:46
  5. Replies: 3
    Last Post: 26th September 2006, 12:16

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.