-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
随机字符串
qsrand(QDateTime::currentMSecsSinceEpoch());
const char ch[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int size = sizeof(ch);
char* str = new char[nLen + 1];
int num = 0;
for (int nIndex = 0; nIndex < nLen; ++nIndex)
{
num = rand() % (size - 1);
str[nIndex] = ch[num];
}
str[nLen] = '\0';
QString res(str);
QLOG_INFO() << __FUNCTION__ << __LINE__ << res;
m_RandomCode = res;blog link [随机字符串](https://holdyounger.github.io/Code/Qt/Qt 随机字符串/)