版本说明:Win10(64bit)、Qt5.12.2、Qt Creator4.8.2
无法添加槽函数,导致信号发出后槽函数接收不到信号
原因1:未在类定义中添加Q_OBJECT
原因2:信号或槽指向的对象未实例化
原因3: 多处包含相同的"ui_XXX.h"头文件
查找/添加槽错误
在UI文件中右键转到槽发生错误,弹窗提示如下:
查找或添加槽错误
The class containing "UI::XXX" could mot be found in :\..\.XXX.cpp.Please verify the #include_directives.
可将.pro文件中,SOURCE+=后面的.cpp文件名全部删除,HEADERS+=后面的.h文件名全部删除重新构建后,再次右键项目文件选择“Add Existing Directory”重新加载文件并重新编译工程。
此时再次添加槽函数
弹窗提示如下:
查找/添加槽错误
No documents matching "ui_XXX.h" could be found .Rebuilding the project might help.
此时并不需要重新编译,直接重启Qt Creator即可。