QTime time; time= QTime::currentTime(); qsrand(time.msec()+time.second()*1000); int xxx=qrand()%5 %5 :在0-4中选出随机数