QMetaObject::connectSlotsByName: No matching signal(QMetaObject::connectSlotsByName: 没有匹配的信号)
问题描述
我设置了一个QT菜单,它自动连接到动作函数on_actionOpen_triggered().后来我想将文件名字符串传递给这个函数,以便在特殊情况下手动调用这个函数.所以我将函数签名更改为 on_actionOpen_triggered( const char *filename_in ).修改后程序运行良好,但终端报错,
I set a QT menu, which is automatically connected with action function on_actionOpen_triggered(). Later I want to pass a filename string to this function in order to call this function manually in a special condition. So I changed the function signature to on_actionOpen_triggered( const char *filename_in ). After this change the program is running well, but there is a complain in terminal,
QMetaObject::connectSlotsByName: on_actionOpen_triggered(const char*) 没有匹配的信号
QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*)
我想知道发生了什么,以及如何为此菜单操作功能添加参数.
I am wondering what happened, and how I can add arguments for this menu action functions.
谢谢.
推荐答案
我遇到了同样的警告/错误 QMetaObject::connectSlotsByName: No matching signal for
并得到了简单的解决方案.例如:
And got simple solution. For Example:
问题:QMetaObject::connectSlotsByName: on_actionOpen_triggered(const char*) 没有匹配的信号 警告您只需要更改 Slot
Problem :
QMetaObject::connectSlotsByName: No matching signal for on_actionOpen_triggered(const char*) Warning
You just need to change the name of the Slot
解决方案
更改插槽名称,如 on_actionOpenTriggered,此警告消失.
提示
Qt 尝试理解其默认插槽,如 on_,因此如果您指定任何具有上述签名的插槽,Qt 将抛出警告.
Hint
Qt try to understand its default slot like on_<name_of_object>_<action>, So if you specify any slot with above signature, Qt will throw warning.
希望对大家有所帮助.
这篇关于QMetaObject::connectSlotsByName: 没有匹配的信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:QMetaObject::connectSlotsByName: 没有匹配的信号
基础教程推荐
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 初始化列表*参数*评估顺序 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
