C++ C++&;PyQt |用于QCheckBox的用户定义插槽和连接

C++ C++&;PyQt |用于QCheckBox的用户定义插槽和连接,c++,pyqt,C++,Pyqt,我想实现一个用户定义的插槽,除了对话框中的复选框之外,还将sender对象作为参数传递 我尝试了以下方法: 插槽: public slots: void updateUI(int, QCheckBox *sender); 连接: connect(this->allLayersetsCheckBox, SIGNAL(stateChanged(int)), this, SLOT(updateUI(int, QCheckBox*))); connect(this->selecte

我想实现一个用户定义的插槽,除了对话框中的复选框之外,还将sender对象作为参数传递

我尝试了以下方法:

插槽:

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;
}
这不可能吗? 或者如何实现这一点

我很想知道哪个复选框正在调用updateUI方法。 我将感谢任何帮助


提前谢谢

如果您想知道哪个对象发送了信号,那么只需在接收槽中使用。这将为您提供一个QObject指针,您可以尝试将其动态转换为适当的类型

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*)