Random number or random string with qt
General and Desktop
2
Posts
2
Posters
4.0k
Views
1
Watching
-
wrote on 23 Nov 2016, 13:48 last edited by
Hi some way to get a random number or string with Qt. I want that these elements dont repeat to get totally random strings or numbers. Any idea it's good received thx.
-
Hi
There is big difference between a random string and just a random number?
Anyway, fast way is justQString MyNum;
int rVal=rand()%1000;
MyNum = QString::number( rVal ) ;If you want truly unique ID, you can use
http://doc.qt.io/qt-5/quuid.html#detailsSo solution also depends on how many you will generate and
how unique it must be. Also over time.
1/2