直接上代码,使用了QuaZip库

void ZipDir(QString strDir,QString strZipFile)
{
	QDir dir = QDir(strDir);
	if(dir.exists() == false)
		return;
	QStringList wrapper = dir.entryList(QDir::Files);
	QuaZip zip(strZipFile);
	zip.setFileNameCodec("IBM866");

	if(!zip.open(QuaZip::mdCreate)){
		qDebug() << "error .... 1";
	}
	QuaZipFile outFile(&zip);
	for(int i = 0 ; i < wrapper.size() ; i++){
		QFileInfo file(strDir+"\\"+wrapper.at(i));
		if(file.exists()){
			QFile inFile ;
			QFile inFileTemp ;			
			inFileTemp.setFileName(file.fileName());
			inFile.setFileName(file.filePath());

			if(!inFile.open(QIODevice::ReadOnly)){
				qDebug() << "error ....2";
				qDebug() << inFile.errorString().toLocal8Bit().constData();
			}

			if(!outFile.open(QIODevice::WriteOnly , QuaZipNewInfo(inFileTemp.fileName() , inFile.fileName()))){
				qDebug() << "error ...3";
			}

			outFile.write(inFile.readAll());

			if(outFile.getZipError() != UNZ_OK){
				qDebug() << "error ...4";
			}

			outFile.close();

			if(outFile.getZipError() != UNZ_OK){
				qDebug() << "error ....5";
			}
			inFile.close();
		}
	}
	zip.close();
	if(zip.getZipError()){
		qDebug() << "error ...6";
	}
}