Qt,没有这样的插槽

时间:2012-05-07 18:54:58

标签: c++ qt

为什么我会这样做

Object::connect: No such slot Ide::on_action_Exit_triggered(index)
Object::connect:  (sender name:   'actionClose_Project')
Object::connect:  (receiver name: 'Ide')

当我尝试这个时:

connect(this->ui->actionClose_Project, SIGNAL(triggered()), this, SLOT(on_action_Exit_triggered(index)));

void Ide::on_action_Exit_triggered(int index)
{
  qDebug()<<"test\n";
}

谢谢。

1 个答案:

答案 0 :(得分:4)

请插入这样的功能原型:

connect(this->ui->actionClose_Project, SIGNAL(triggered()), this, SLOT(on_action_Exit_triggered(int)));

您使用此格式并不常见于使用插槽。信号和插槽的参数应相同。