Results 1 to 3 of 3

Thread: How can i delay a function?

  1. #1
    Join Date
    Jan 2007
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How can i delay a function?

    I want to paint how the value change to newValue , so when the value increase a step,i want to repaint it .I use the code like this ,but it didn't work well:When the value increase ,it didn't repaint;but when the value changed to newValue, it repainted 10 times. Where was wrong? Thanks
    Qt Code:
    1. void Board::setValue(int newValue)
    2. {
    3. int i=1;
    4. int oldValue=value;
    5. for(i=1;i<11;i++)
    6. {
    7. value=oldValue+(newValue-oldValue)/10*i;
    8. qDebug("%d",value);
    9. QTimer::singleShot(1000,this,SLOT(repaint()));
    10. // repaint();
    11. // sleep(1);
    12. }
    13.  
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Russia
    Posts
    50
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can i delay a function?

    Because repaint function inside a loop.

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How can i delay a function?

    update() and QCoreApplication:rocessEvents()
    might help you...
    use the update to repaint... and processEvents to reflect the updation..

Similar Threads

  1. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  2. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  3. Qt 4.1.4 plugin QPSQL
    By jcr in forum Installation and Deployment
    Replies: 4
    Last Post: 22nd June 2006, 22:55
  4. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52
  5. use libs under qt4
    By raphaelf in forum Qt Programming
    Replies: 6
    Last Post: 27th February 2006, 17:59

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.