代碼:
#include <QUuid> QUuid id = QUuid::createUuid(); QString strId = id.toString(); qDebug() << strId; //輸出結果:"{b5eddbaf-984f-418e-88eb-cf0b8ff3e775}" strId.remove("{").remove("}").remove("-"); // 一般習慣去掉左右花括號和連字符 qDebug() << strId; //輸出結果:"b5eddbaf984f418e88ebcf0b8ff3e775"
轉自:https://blog.csdn.net/u014746838/article/details/78442680