Results 1 to 3 of 3

Thread: fade from one colour to another

  1. #1
    Join Date
    Jun 2008
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Question fade from one colour to another

    Hi

    A small question, from a QT newbie.

    I have a small box painted in the painEvent, and I want the colour to fade from one colour to another, over time.

    I hope someone have an idea how to do this.

    Thanks
    Søren- DK.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: fade from one colour to another

    First you need a QTimer or QTimeLine that will fire QWidget::update() (or a custom slot which calls update()). The second thing you need to do is to change paintEvent() so that it reads the current state of the animation from somewhere and paints it. The last thing is to keep change the state somehow.

    Note that you shouldn't update the animation state in paintEvent() because you can never know when it will be called.

  3. #3
    Join Date
    Jun 2008
    Posts
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Wink Re: fade from one colour to another

    Thanx..

    Søren - DK

Similar Threads

  1. Changing QPushButton text colour with mouseMoveEvent
    By Misenko in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2008, 16:53
  2. Changing colour thru qss file
    By phillip_Qt in forum Qt Programming
    Replies: 3
    Last Post: 27th March 2008, 05:36
  3. Window colour
    By phillip_Qt in forum Qt Programming
    Replies: 24
    Last Post: 28th February 2008, 06:25
  4. Dynamically changing QLabel background colour
    By T4ng10r in forum Qt Programming
    Replies: 19
    Last Post: 19th April 2007, 12:47
  5. background colour
    By kw in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2006, 00:44

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.