QMetaObject :: connectSlotsByName:没有匹配的信号 [英] QMetaObject::connectSlotsByName: No matching signal

查看:2582
本文介绍了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.

谢谢。

推荐答案

Qt自动连接机制无法找到合适的信号。对于菜单项,没有任何信号可以匹配您的插槽与一个参数,并且信号不能的参数少于插槽。

Qt autoconnection mechanism can't find suitable signal to your slot. For menu item there's no signal that would match your slot with one argument, and signal must not have fewer arguments than slot.

槽的名称,以便它不会尝试找到匹配的信号,并直接使用 QObject :: connect 而不是 QMetaObject :: connectSlotsByName 。此外,如果您要连接使用<$ c $,您必须为您的参数 filename_in c>触发信号。

You can change slot's name so that it won't try to find a matching signal, and use QObject::connect directly instead of QMetaObject::connectSlotsByName. Moreover you'll have to assign default value to your argument filename_in if you want connect to work with triggeredsignal.

这篇关于QMetaObject :: connectSlotsByName:没有匹配的信号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆