在Qt4中创建随机字符串或数字 [英] Create a random string or number in Qt4

查看:78
本文介绍了在Qt4中创建随机字符串或数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有可以创建完全随机的字符串或数字的功能或类似功能?

Is there any function or something like that by which I can create totally random strings or numbers?

推荐答案

您可以使用 QUuid 类,该类会生成通用唯一标识符.这些不是完全随机的",但它们是唯一的.

You can create random numbers using qrand. If you need strings, you can convert the int to string. You could also check the QUuid class, which generates Universally Unique Identifiers. Those are not 'totally random', but they are unique.

这篇关于在Qt4中创建随机字符串或数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆