PDA

View Full Version : Need simple example with OSDaB-Zip unzip file



noborder
16th January 2013, 12:50
Need simple example with OSDaB-Zip unzip file

MainWindow on QFileDialog::getOpenFileName .... emit signal with file name to slot unzip

something this

osdab example hard for me

zgulser
16th January 2013, 13:27
I have no information about QSDaB but Quazip is another and maybe simplier way to handle zip files.

ChrisW67
17th January 2013, 21:59
I don't think there could be a simpler example than those on the OSDaB Zip page on how to use their Zip package. However, your question does not seem to be about the Zip package at all. You want to get the file name of an existing zip file and unzip it.

Something like this (untested) somewhere in your main window code:


QString defaultPath = QDesktopServices::storageLocation(QDesktopServices ::DocumentsLocation);
QString zipFile = QFileDialog::getOpenFileName(this, tr("Select Zip File"), defaultPath, tr("Zip files (*.zip)"));
if (!zipFile.isEmpty()) {
// Code to do whatever work.
UnZip uz;
UnZip::ErrorCode ec = uz.openArchive(zipFile);
if (ec == UnZip::Ok) {
// Need to list the files in this archive?
QStringList list = uz.getFileList();
// emit signals, extract files, get contained file details, do whatever else
// make macramé owl ;)
}
else {
// Report error etc.
}
}