QT 随机字符串

void testClass::setRandString(QString & randString){ int max = 8; QString tmp = QString("0123456789ABCDEFGHIJKLMNOPQRSTUVWZYZ"); QString str = QString(); QTime t; t= QTime::currentTime(); qsrand(t.msec()+t.second()*1000); for(int i=0;i<max;i++) { int ir = qrand()%tmp.length(); str[i] = tmp.at(ir); } randString = str; }

你可能感兴趣的:(qt)