Qt5 嘈杂的调试消息 "XI2 mouse release ... source MouseEventNotSynthesized"
Qt5 noisy debug messages "XI2 mouse release ... source MouseEventNotSynthesized"
如何抑制像
这样的 Qt5 调试消息
XI2 mouse motion 331,150, time 188607671, source MouseEventNotSynthesized
当 运行 我的 GUI 程序的调试版本时正在淹没控制台?
前史与分析:最近将Debian(buster)包libqt5core5a升级到5.9.2+dfsg-6版本后,Qt5不再打印调试信息。 qDebug() << ...
和 qDebug(...)
都不起作用。在我的程序中,这些消息是通过全局函数处理的
void messageHandler(QtMsgType type, QMessageLogContext const& ctx, rcstr msg) {
switch (type) {
case QtDebugMsg:
std::cerr << ".... " << msg.toStdString() << /*context(ctx) <<*/ "\n" << std::flush;
break;
...
}
}
由语句
激活
qInstallMessageHandler(messageHandler);
升级后,qDebug
语句将不再导致调用 messageHandler
。
这种不受欢迎的行为是由于文件 /etc/xdg/QtProject/qtlogging.ini
造成的,它随 libqt5core5a
一起提供,内容为
[Rules]
*.debug=false
在http://doc.qt.io/qt-5/qloggingcategory.html之后,我用语句
覆盖了这些设置
QLoggingCategory::setFilterRules("*.debug=true");
在我的代码中。事实上,我的调试信息又出现了。然而,随之而来的是开头描述的不需要的消息开始充斥控制台。从 Qt 文档中可以清楚地看出,过滤规则可以像
这样细化
QLoggingCategory::setFilterRules("*.debug=true;foo.bar.debug=false");
经过这么长的史前历史和分析,我的问题很简单:用什么代替 foo.bar
来摆脱鼠标移动消息?
QLoggingCategory::setFilterRules("*.debug=true\nqt.*.debug=false");
这概括了@G.M在评论中指出的答案,并更正了a bug in the Qt doc:分隔符需要是"\n"
,而不是";"
。
如何抑制像
这样的 Qt5 调试消息XI2 mouse motion 331,150, time 188607671, source MouseEventNotSynthesized
当 运行 我的 GUI 程序的调试版本时正在淹没控制台?
前史与分析:最近将Debian(buster)包libqt5core5a升级到5.9.2+dfsg-6版本后,Qt5不再打印调试信息。 qDebug() << ...
和 qDebug(...)
都不起作用。在我的程序中,这些消息是通过全局函数处理的
void messageHandler(QtMsgType type, QMessageLogContext const& ctx, rcstr msg) {
switch (type) {
case QtDebugMsg:
std::cerr << ".... " << msg.toStdString() << /*context(ctx) <<*/ "\n" << std::flush;
break;
...
}
}
由语句
激活qInstallMessageHandler(messageHandler);
升级后,qDebug
语句将不再导致调用 messageHandler
。
这种不受欢迎的行为是由于文件 /etc/xdg/QtProject/qtlogging.ini
造成的,它随 libqt5core5a
一起提供,内容为
[Rules]
*.debug=false
在http://doc.qt.io/qt-5/qloggingcategory.html之后,我用语句
覆盖了这些设置QLoggingCategory::setFilterRules("*.debug=true");
在我的代码中。事实上,我的调试信息又出现了。然而,随之而来的是开头描述的不需要的消息开始充斥控制台。从 Qt 文档中可以清楚地看出,过滤规则可以像
这样细化QLoggingCategory::setFilterRules("*.debug=true;foo.bar.debug=false");
经过这么长的史前历史和分析,我的问题很简单:用什么代替 foo.bar
来摆脱鼠标移动消息?
QLoggingCategory::setFilterRules("*.debug=true\nqt.*.debug=false");
这概括了@G.M在评论中指出的答案,并更正了a bug in the Qt doc:分隔符需要是"\n"
,而不是";"
。