使用静态版本的Qt编译时,文件对话框崩溃

时间:2019-07-05 21:53:19

标签: c++ qt ubuntu static-linking

我有一个带有C ++ Qt前端的Rust项目。我在Mint 19上使用静态版本Qt编译了Linux版本。我被告知(https://github.com/spieglt/Cloaker/issues/2),在左侧边栏中选择Computer或键入/作为路径时,文件对话框崩溃。我发现使用Qt静态版本(https://imgur.com/a/4grBpVY)时看到的文件对话框与使用Qt安装程序制作的标准动态链接版本(https://imgur.com/a/lzhOnkA)编译时看到的对话框不同。

用户计算机上的输出为:

./Cloaker.run 
QApplication: invalid style override passed, ignoring it.
    Available styles: Windows, Fusion
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Case insensitive sorting unsupported in the posix collation implementation
Numeric mode unsupported in the posix collation implementation
Segmentation fault (core dumped)

我尝试在Ubuntu上使用静态版本的Qt进行编译。当我这样做时,程序不会在出现破碎的文件对话框时崩溃,但是Computer是边栏和顶部栏中唯一未显示为灰色的项目,输出为


    QPixmap::scaleWidth: Pixmap is a null pixmap
    QPixmap::scaleWidth: Pixmap is a null pixmap
    QPixmap::scaleWidth: Pixmap is a null pixmap
    QPixmap::scaleWidth: Pixmap is a null pixmap
    Case insensitive sorting unsupported in the posix collation implementation
    Numeric mode unsupported in the posix collation implementation
    QPixmap::scaleWidth: Pixmap is a null pixmap
    QPixmap::scaleWidth: Pixmap is a null pixmap
    QPixmap::scaleWidth: Pixmap is a null pixmap
    Case insensitive sorting unsupported in the posix collation implementation
    Numeric mode unsupported in the posix collation implementation
    Case insensitive sorting unsupported in the posix collation implementation
    Numeric mode unsupported in the posix collation implementation
    Empty filename passed to function
    QPainter::begin: Paint device returned engine == 0, type: 3
    QPainter::setCompositionMode: Painter not active
    QPainter::end: Painter not active, aborted
    Case insensitive sorting unsupported in the posix collation implementation
    Numeric mode unsupported in the posix collation implementation

原始薄荷配置命令: ~/Qt/5.12.3/Src/configure -prefix ~/qt-static/5.12.3 -static -release -opensource -confirm-license -skip multimedia -no-compile-examples -nomake examples -no-openssl -no-libpng -skip wayland -qt-xcb

Ubuntu configure命令: ~/Qt/5.13.0/Src/configure -static -release -prefix ~/qt-static/install -opensource -confirm-license -no-compile-examples -nomake examples -no-openssl -no-libpng -fontconfig

文件对话框代码:

    if (mode == Encrypt) { // encrypt, append extension
        inFile += QString::fromUtf8(FILE_EXTENSION);
        return QFileDialog::getSaveFileName(nullptr, "Save encrypted file", inFile, "", nullptr, QFileDialog::DontConfirmOverwrite);
    } else { // decrypt, chop off extension if there, otherwise prepend decrypted.
        if (inFile.endsWith(FILE_EXTENSION, Qt::CaseInsensitive)) {
            inFile = inFile.left(inFile.length() - strlen(FILE_EXTENSION));
        } else {
            inFile += QString::fromUtf8("_decrypted");
        }
        // save as dialog, return path
        return QFileDialog::getSaveFileName(nullptr, "Save decrypted file", inFile, "", nullptr, QFileDialog::DontConfirmOverwrite);
    }

我想在静态链接Qt时获得正常的GNOME文件对话框。如果这不可能,那么AppImage会有同样的问题吗?

1 个答案:

答案 0 :(得分:0)

结果是我刚才构建的Qt静态版本不正确。要在Mint上使用工作文件对话框(Qt窗口小部件,QFileDialog样式;不是GTK样式)构建静态Qt:

$ mkdir ~/qt-static && cd ~/qt-static
$ mkdir build install; cd build
$ ~/Qt/5.12.3/Src/configure -prefix ~/qt-static/install -static -release -opensource -confirm-license -skip multimedia -skip webengine -skip wayland -no-compile-examples -nomake examples -no-openssl -ico -gtk -gif -qt-xcb
$ make -j8

Ubuntu相同,除了没有-qt-xcb和带有-fontconfig