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

标签 c++ qt ubuntu static-linking

我有一个带有 C++ Qt 前端的 Rust 项目。我用静态版本的 Qt 在 Mint 19 上编译了 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

原始 Mint 配置命令: ~/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 配置命令: ~/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 会不会有同样的问题?

最佳答案

原来我错误地构建了 Qt 的静态版本。要在 Mint 上构建带有工作文件对话框(Qt Widgets、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

除了没有 -qt-xcb-fontconfig 外,Ubuntu 是一样的。

关于c++ - 使用 Qt 的静态版本编译时文件对话框崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56909597/

相关文章:

c++ - visual c++并口控制

c++ - C++中的最大线程数

c++ - 插槽在 QT 应用程序中未接收到信号

apache - 如何在 ubuntu 中配置 Apache 服务器以在本地运行站点?

c++ - 关于 C++0x,我需要了解什么?

c++ - QProcess::startDetached() 不显示控制台窗口

c++ - QT 如何获取 XML 文件的最后一个节点?

android - 启动外部 Activity 以扫描条形码

linux - 如何将 cuDNN 更新到新版本?

c++ - 在 Linux 环境中使用 C++ 的 BLE 服务器端实现