当前位置:网站首页>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
边栏推荐
- The 2021 IT industry project management survey report was released!
- CPT 104_TTL 09
- 可执行程序执行流程
- Phlli in a VM node
- QT drawpixmap and DrawImage blur problem
- Traversal array, object parent-child communication props / $emit
- node中的redis使用--ioredis
- Vscode settings JSON configuration
- FileReader API file operation
- selenium预先加载cookie的必要性
猜你喜欢
If I am PM's performance, movie VR ticket purchase display
Necessity of selenium preloading cookies
QSS, qdateedit, qcalendarwidget custom settings
Camera imaging + homography transformation + camera calibration + stereo correction
Graphics. Fromimage reports an error "graphics object cannot be created from an image that has an indexed pixel..."
uni使用的一些坑
Nécessité de précharger les cookies dans le sélénium
Generation of straightening body in 3D slicer
selenium預先加載cookie的必要性
How to add beautiful code blocks in word | a very complete method to sort out and compare
随机推荐
Wbpack configuring production development environment
Use of qwbengneview and qwebchannel.
Ehcache Memcache redis three caches
Use of uniapp native plug-ins
How to set the initial value of El input number to null
WTL self drawn control library (cqscheckcomboxbox)
If the route reports an error after deployment according to the framework project
(十一)vscode代码格式化配置
Click the Add button - a box appears (similar to adding learning experience - undergraduate - Graduate)
Various situations of data / component binding
How to add beautiful code blocks in word | a very complete method to sort out and compare
创建进程内存管理copy_mm - 进程与线程(九)
Graphics. Fromimage reports an error "graphics object cannot be created from an image that has an indexed pixel..."
Parsing of string class intern() method
C test calls the paddlesharp module to recognize pictures and words
The 2021 IT industry project management survey report was released!
MySQL series - install MySQL 5.6.27 on Linux and solve common problems
(11) Vscode code formatting configuration
CORS and proxy (づ  ̄ 3  ̄) in egg ~ the process of stepping on the pit and filling the pit ~ tot~
Rog attack