gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 12:34:44 34 4
gpt4 key购买 nike

我有一个带有 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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com