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
void Board::setValue(int newValue)
{
int i=1;
int oldValue=value;
for(i=1;i<11;i++)
{
value=oldValue+(newValue-oldValue)/10*i;
qDebug("%d",value);
QTimer::singleShot(1000,
this,
SLOT(repaint
()));
// repaint();
// sleep(1);
}
}
void Board::setValue(int newValue)
{
int i=1;
int oldValue=value;
for(i=1;i<11;i++)
{
value=oldValue+(newValue-oldValue)/10*i;
qDebug("%d",value);
QTimer::singleShot(1000,this,SLOT(repaint()));
// repaint();
// sleep(1);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks