c++ - 为什么调用 QFileDialog::getSaveFileName() 会在 Linux 上重置已安装的 Qt 消息处理程序?
问题描述
调用对话框会重置 debian(如 linux)中的消息处理程序
是的,这里不再需要详细信息,但我必须添加此文本才能通过智能机器人
#include <QApplication>
#include <QFileDialog>
#include <QDebug>
QtMessageHandler defaultHandler;
void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
auto str = msg;
str.append(" handled");
defaultHandler(type, context, str);
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
qDebug() << "test0";
defaultHandler = qInstallMessageHandler(messageHandler);
qDebug() << "test1";
QFileDialog::getSaveFileName();
qDebug() << "test2";
}
在窗口中输出
test0
test1 handled
test2 handled
像linux一样在debian中输出
test0
test1 handled
warning: QFSFileEngine::open: No file name specified
debug: test2
解决方案
推荐阅读
- groovy - Groovy 中有没有办法收集列表中的所有对象,其中成员变量与另一个列表中的值匹配?
- javascript - 小数javascript中的数字数据类型
- selenium - 与 Kubernetes 一起部署时,Selenium Hub 无法处理测试队列
- node.js - 如何使用fluent-ffmpeg在nodejs上处理正确的ffmpeg命令?
- assembly - 8086 机器语言:简单程序不起作用
- jquery - JQuery keyup 不会引起警报
- javascript - 为什么它返回未定义的值?
- python - html和flask中拨动开关的值
- asp.net - cookie 不在 ios12 设备的请求中
- python - [Python][Tkinter] 添加标志使标签的前景在循环中变为红色?