自定义信号与no matching function for call to ‘softkey::connect(QLabel*&, void (mylabel::)(), softkey, void (softkey:😃())出现的问题
自定义了close_key信号
class mylabel : public QLabel
{
Q_OBJECT
public:
explicit mylabel(QWidget *parent = Q_NULLPTR);
bool event(QEvent *e) override
{
if(e->type() == QEvent :: MouseButtonPress){
emit close_key();
return true;
}
return QLabel::event(e);
}
signals:
void close_key();
};
设置响应函数为hide_widget
void softkey::hide_widget()
{
ui->myWidget->hide();
}
添加connect函数
connect(ui->backgroundlabel,&mylabel::close_key,this,&softkey::hide_widget);
出现bug 
解决方法:

backgroundlabel类型应该改为自定义的mylabel类型,否则无法响应    再次运行就可以成功!!!
|