//比较两个Map是否相同
void MainWindow::CompareMap(QMap<QString, QString> &dirMap, QMap<QString, QString> &txtMap)
{
//QFile OKFile("D:/Qtproject/IdentificationFile/OK.txt");
//QFile NGFile("D:/Qtproject/IdentificationFile/NG.txt");
//OKFile.open(QIODevice::WriteOnly|QIODevice::Text);
//NGFile.open(QIODevice::WriteOnly|QIODevice::Text);
for(auto it=txtMap.constBegin();it!=txtMap.constEnd();++it)
{
//有相同的键值对
if(dirMap.contains(it.key())&& dirMap.value(it.key()) == it.value())
{
//QTextStream out(&OKFile);
//ui->listWidget_2->addItem("/home/zhenjiang_peng/yolov5-reid/savepath/"+it.key()+"/ "+it.value());
//ui->lineEdit_2->setText(QString::number(ui->listWidget_2->count()));
//OKFile.write("/home/zhenjiang_peng/yolov5-reid/savepath/"+it.key()+"/ "+it.value());
//out<<(QString)"/home/zhenjiang_peng/yolov5-reid/savepath/"<<it.key()<<"/ "<<it.value()<<"\n";
}
else//不正确
{
//QTextStream out(&NGFile);
//ui->listWidget->addItem("/home/zhenjiang_peng/yolov5-reid/savepath/"+it.key()+"/ "+it.value());
//ui->lineEdit_3->setText(QString::number(ui->listWidget->count()));
//out<<(QString)"/home/zhenjiang_peng/yolov5-reid/savepath/"<<it.key()<<"/ "<<it.value()<<"\n";
}
}
}
Qt 比较两个QMap是否具有相同的键值对
最新推荐文章于 2023-12-15 18:56:50 发布