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 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?
// emit signals, extract files, get contained file details, do whatever else
// make macramé owl ;)
}
else {
// Report error etc.
}
}
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.
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks