iswaryasenthilkumar
8th July 2015, 16:01
i getting sequence random number when opening closing and opening the app.My code below:
int Widget::GetRandomString()
{
QString possibleCharacters("0123456789");
int randomStringLength = 4;
QString randomString;
for(int i=0; i<randomStringLength; ++i)
{
int index = qrand() % possibleCharacters.length();
QChar nextChar = possibleCharacters.at(index);
randomString.append(nextChar);
}
QFile newfile(PASSCODEFILEPATH);
if (!newfile.open(QIODevice::ReadWrite))
{
return FAIL;
}
QTextStream out(&newfile);
out << randomString.toInt();
newfile.close();
}
i getting the output:
3781
7983
1267
9819
1307
5578
..
i getting these output only,,i need if i run the app output should like 3756 and close the app again open tha app output should be different from previous output.please QT Expered guide me to get proper result,
Thanks in advance:)
int Widget::GetRandomString()
{
QString possibleCharacters("0123456789");
int randomStringLength = 4;
QString randomString;
for(int i=0; i<randomStringLength; ++i)
{
int index = qrand() % possibleCharacters.length();
QChar nextChar = possibleCharacters.at(index);
randomString.append(nextChar);
}
QFile newfile(PASSCODEFILEPATH);
if (!newfile.open(QIODevice::ReadWrite))
{
return FAIL;
}
QTextStream out(&newfile);
out << randomString.toInt();
newfile.close();
}
i getting the output:
3781
7983
1267
9819
1307
5578
..
i getting these output only,,i need if i run the app output should like 3756 and close the app again open tha app output should be different from previous output.please QT Expered guide me to get proper result,
Thanks in advance:)