当前位置:网站首页>QT compressed folder
QT compressed folder
2022-04-23 05:30:00 【Oriental forgetfulness】
Adopted QZipWriter Of addFile To achieve .
First step :pro Add... To the file QT += gui-private
The second step : Add... To the header file :
#include <QtGui/private/qzipreader_p.h>
#include <QtGui/private/qzipwriter_p.h>
The third step :cpp Implementation in file :
bool zipDir(const QString& dirPath,QString SavePath)
{
bool ret;
QZipWriter *writer = new QZipWriter(SavePath);
if(QZipWriterEx(writer,dirPath,dirPath))
ret=true;
else
ret=false;
writer->close();
delete writer;
return ret;
}
bool QZipWriterEx(QZipWriter *writer, QString tmpPath, QString basePath)
{
QDir dir(tmpPath);
foreach (QFileInfo info, dir.entryInfoList())
{
if (info.fileName() == "." || info.fileName() == "..")
continue;
if (info.isFile())
{
QFile upfile(info.filePath());
upfile.open(QIODevice::ReadOnly);
QString fileName = info.filePath().mid(basePath.size()+1,info.filePath().size());
writer->addFile(fileName,upfile.readAll());
qDebug()<<fileName<<tmpPath<<basePath;
upfile.close();
}
else if (info.isDir())
{
QZipWriterEx(writer,info.filePath(),basePath);
}
}
return true;
版权声明
本文为[Oriental forgetfulness]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220543306776.html
边栏推荐
- Similarities and differences between vector and array (notes)
- Simple and basic use of switch and if
- 2021-09-28
- Add two pointers? (legal or illegal)
- selenium预先加载cookie的必要性
- Click the Add button - a box appears (similar to adding learning experience - undergraduate - Graduate)
- Why can't V-IF and V-for be used together
- Executable program execution process
- [the background color changes after clicking a line]
- Multiple mainstream SQL queries only take the latest one of the data
猜你喜欢

Good test data management, in the end how to do?

Generation of straightening body in 3D slicer

varnish入门

Cross domain CORS relationship~

QSS, qdateedit, qcalendarwidget custom settings

Three methods of list rendering

Parameter analysis of open3d material setting

Branch and loop statements
![[the background color changes after clicking a line]](/img/3a/709d47fd3a370d86569fb9b560b403.png)
[the background color changes after clicking a line]

After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
随机推荐
Cmake basic tutorial (39) pkgconfig
Cross platform packaging of QT packaging program
世界与个人发展
Use of ES6 array
Redis的基本知识
Simple and basic use of switch and if
Similarities and differences between vector and array (notes)
Three 之 three.js (webgl)模型的删除/场景的清空/内存的释放 的简单整理
CMake基础教程(39)pkgconfig
uni使用的一些坑
五一劳动节期间什么理财产品会有收益?
QT drawpixmap and DrawImage blur problem
The title bar will be pushed to coincide with the status bar
Note: unordered_ Understanding and use of map
If I am PM's performance, movie VR ticket purchase display
Uncle wolf is looking for a translator -- Plato -- ongoing translation
Nécessité de précharger les cookies dans le sélénium
Laravel routing settings
MySQL series - install MySQL 5.6.27 on Linux and solve common problems
[no title] Click the classification jump page to display the details