我想实现一个用户定义的插槽,除了对话框中的复选框外,还将发送方对象作为参数传递。
我尝试了以下内容:
槽
public slots:
void updateUI(int, QCheckBox *sender);
连接:
connect(this->allLayersetsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateUI(int, QCheckBox*)));
connect(this->selectedLayersetsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateUI(int, QCheckBox*)));
connect(this->unselectedLayersetsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateUI(int, QCheckBox*)));
方法:
void MyDialog::updateUI(int state, QCheckBox *sender) {
cout << "updateUI" << endl;
cout << qPrintable( sender->text() ) << endl;
}
我收到以下错误:
QObject::connect: Incompatible sender/receiver arguments
QCheckBox::stateChanged(int) --> MyDialog::updateUI(int,QCheckBox*) QObject::connect: Incompatible sender/receiver arguments
QCheckBox::stateChanged(int) --> MyDialog::updateUI(int,QCheckBox*) QObject::connect: Incompatible sender/receiver arguments
QCheckBox::stateChanged(int) --> MyDialog::updateUI(int,QCheckBox*)
这不可能吗? 或者如何实现这个?
我真的想知道哪个CheckBox正在调用updateUI方法。 我将不胜感激任何帮助。
提前致谢!