1

我收到这个错误QObject::installEventFilter(): Cannot filter events for objects in a different thread。我已经读到,当不在主线程而是在另一个线程中执行 GUI 操作时,可能会出现此错误。但是我的程序是单线程的。我有一个 QMainwindow。我也从不安装任何事件过滤器。也许 Qt 创建了一些其他线程或事件过滤器?我无法发布代码,因为它非常庞大,而且我不知道错误是从哪里发布的。所以我的问题是如何获得有关错误的更多信息?我可以确切地知道 Qt 尝试导致错误的原因吗?错误也具有随机特征:有时是错误消息,有时是Bus error,有时segmentation fault有时没有任何问题。

使用 GDB,我得到了堆栈,但唯一的来源是 main.c,其中称为 application.exec(),其他框架是 Qt 库

0  0x0000002a969983bc in QObject::installEventFilter () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
1  0x0000002a9625a75d in QAbstractItemView::commitData () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
2  0x0000002a96991d58 in QMetaObject::activate () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
3  0x0000002a9640404f in QAbstractItemDelegate::commitData () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
4  0x0000002a963184cf in QStyledItemDelegate::qt_static_metacall () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
5  0x0000002a9699820e in QObject::event () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
6  0x0000002a95c75e00 in QApplicationPrivate::notify_helper () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
7  0x0000002a95c7e6ff in QApplication::notify () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
8  0x0000002a9697a13b in QCoreApplication::notifyInternal () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
9  0x0000002a9697c42d in QCoreApplicationPrivate::sendPostedEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
10 0x0000002a969ae973 in ?? () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
11 0x000000315bc266bd in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0
12 0x000000315bc28397 in ?? () from /usr/lib64/libglib-2.0.so.0
13 0x000000315bc288eb in g_main_context_iteration () from /usr/lib64/libglib-2.0.so.0
14 0x0000002a969af4f5 in QEventDispatcherGlib::processEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
15 0x0000002a95d2e6f9 in QGuiEventDispatcherGlib::processEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtGui.so.4
16 0x0000002a96978f13 in QEventLoop::processEvents () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
17 0x0000002a969793c1 in QEventLoop::exec () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
18 0x0000002a9697c76f in QCoreApplication::exec () from /home/aminasya/checkout/ToT_test_072213/ic/ic_superproj/aof-dbg/Mgc_home//pkgs/icv_lib/lib64/libQtCore.so.4
19 0x000000000423122e in nlb::application::runGuiMode (argc=1, argv=0x7fbfffe888, args=
      {mode = nlb::application::Application::MODE_GUI, databasePath = {static null = {<No data fields>}, static shared_null = {ref = {_q_value = 805}, alloc = 0, size = 0, data = 0x6b8d79a, clean
= 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, static shared_empty = {ref = {_q_value = 25}, alloc = 0, size = 0, data = 0x2a96bef7da, clean = 0, s
impletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x2a96bef7c0, static codecForCStrings = 0x0}, scriptPath = {static null = {<No data fields>}, static s
hared_null = {ref = {_q_value = 805}, alloc = 0, size = 0, data = 0x6b8d79a, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, static shared_emp
ty = {ref = {_q_value = 25}, alloc = 0, size = 0, data = 0x2a96bef7da, clean = 0, simpletext = 0, righttoleft = 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x6b8d780, static c
odecForCStrings = 0x0}, scriptArgs = {static null = {<No data fields>}, static shared_null = {ref = {_q_value = 805}, alloc = 0, size = 0, data = 0x6b8d79a, clean = 0, simpletext = 0, righttoleft
= 0, asciiCache = 0, capacity = 0, reserved = 0, array = {0}}, static shared_empty = {ref = {_q_value = 25}, alloc = 0, size = 0, data = 0x2a96bef7da, clean = 0, simpletext = 0, righttoleft = 0, a
sciiCache = 0, capacity = 0, reserved = 0, array = {0}}, d = 0x6b8d780, static codecForCStrings = 0x0}, help = false}, initialArgumentParsingSuccessed=true) at Isrc/NLBMain.C:366
4

1 回答 1

4

如果您使用 QtCreator 设置“调用 qWarning() 时停止”选项,该选项位于选项 -> 调试器 -> GDB 扩展中。

之后以调试模式 (F5) 启动您的应用程序。当发出该警告时,QtCreator 将停止您的应用程序。遍历堆栈以查找可能的错误位置。

如果您不使用 QtCreator,请尝试在 GDB 下启动您的应用程序并在qWarning().

于 2013-08-13T12:10:18.940 回答