QT信号槽报错no matching member function for call to 'connect'
QT信号槽报错no matching member function for call to 'connect'
问题
connect(dynamic_cast<AnalyseWindow*>(parent),&AnalyseWindow::sigStart,timerRefresh,&QTimer::start,Qt::DirectConnection);
报错信息:
chartform.cpp:59:5: error: no matching member function for call to 'connect' qobject.h:222:36: note: candidate function not viable: no known conversion from 'void (AnalyseWindow::*)()' to 'const char *' for 2nd argument qobject.h:225:36: note: candidate function not viable: no known conversion from 'void (AnalyseWindow::*)()' to 'const QMetaMethod' for 2nd argument qobject.h:242:43: note: candidate template ignored: couldn't infer template argument 'Func2' qobject.h:283:13: note: candidate template ignored: couldn't infer template argument 'Func2' qobject.h:322:13: note: candidate template ignored: couldn't infer template argument 'Func2' qobject.h:274:13: note: candidate function template not viable: requires 3 arguments, but 5 were provided qobject.h:314:13: note: candidate function template not viable: requires 3 arguments, but 5 were provided qobject.h:481:41: note: candidate function not viable: requires at most 4 arguments, but 5 were provided
原因
有多种:
- 参数不是继承自
QObject
的对象,或者没有导入Qt
命名空间。 - 信号和槽的参数列表不匹配。信号的参数个数 >= 槽的参数个数且信号和槽的参数类型也必须匹配
- 函数指针类型不匹配。
- 在进行
connect
连接时,有可能会遇到无法匹配的候选函数。在这种情况下,可以通过使用QObject::connect
函数的第五个参数,来强制选择合适的函数。
本文作者:3的4次方
本文链接:https://www.cnblogs.com/3to4/p/17496708.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
分类:
标签:
,
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步