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