繁体   English   中英

QtDesigner和QuaZip问题

[英]QtDesigner and QuaZip issue

不知道有多少人使用QuaZip在Qt中打开和使用zip文件,但是我正尝试使用以下代码打开zip文件:

#include "quazip/JlCompress.h"

#include <QDebug>
#include <QtWidgets>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
ui->setupUi(this);
ConnectActions();
...
}

bool MainWindow::LoadArchive(const QString &filename)
{
    //qDebug() << "STUB: LoadArchive()";

    QuaZip archive_handle(filename);
    //Attempt to open the file, return false and display error message
    if(!archive_handle.open(QuaZip::mdUnzip)) {
        qDebug() << "Archive does not exist or is damaged!";
        return false;
    }
    //Perform some sort of operation, such as loading the images out of the archive

    //tidy up
    archive_handle.close();
    return true;

}

它给了我错误:

QIODevice::open: File access not specified
Archive does not exist or is damaged!
***Error in `/home/adrian/Development/build-CinemaStrips-Desktop_Qt_5_3_GCC_64bit-Debug/CinemaStrips': free(): invalid pointer: 0x00007f2c4b709ce0***
The program has unexpectedly finished.

由于API指令非常简单,而且我在代码中逐字遵循它们,因此我无法判断是否缺少步骤。 如您所见,我正在使用Qt5; QuaZip仅适用于4? 最后,还有其他人可以使用的Qt中的zip文件处理方法吗?

谢谢!

要回答我自己的问题,似乎我的问题是Qt项目文件中quazip库的相对路径解析之一。 在使用相对路径在.pro中指定库时,必须记住Qt在运行二进制文件时会从二进制位置解析相对库路径。 另一方面,我是从.pro(和我的代码库)位置的角度指定库的位置。 纠正后,我的错误得到了缓解。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM