【发布时间】:2014-03-13 20:51:13
【问题描述】:
除了对话框中的复选框之外,我还想实现一个用户定义的插槽,它将发送者对象作为参数传递。
我尝试了以下方法:
插槽:
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 方法。 我将不胜感激。
提前致谢!
【问题讨论】: