直接上代码吧,qt得到文件md5的值应该还是比较常用到的一个功能。
QString ThreadDownload::getFileMd5(QString filename)
{
QFile theFile(filename);
if(!theFile.open(QIODevice::ReadOnly)){
return "failed";
}
QByteArray ba = QCryptographicHash::hash(theFile.readAll(), QCryptographicHash::Md5);
theFile.close();
return QString(ba.toHex());
}