Fork me on GitHub

Qt生成随机名,用于打印log

Qt生成随机名,用于打印log

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

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);
}
QString strPath = "/home/zhangpf/piclog/";
strPath += str;
strPath += ".png";