情况是:在“创建课程”中,我单击“Save1”按钮(时间 1,它调用 setUpStep2Action()),进入第 2 步并禁用“Save1”按钮......保存所有信息后,我添加更多课程,因此启用“Save1”按钮。当我单击“Save1”按钮(时间 2)时,它会调用 setUpStep2Action() 2 次。我不知道发生了什么以及如何防止这个问题。谢谢。
无效 step2SaveAction(int courseId) {
int numElement = ui.rightWidget->count();
if(numElement == 0)
{
QMessageBox::warning(this,tr("Skill choice"),tr("Please choose skills!!"));
return;
}
char* method = "CREATE";
if ( courseId !=0)
method = "EDIT";
setup4Step3(method,courseId,numElement );
ui.addMoreButton->setVisible(true);
}
我把连接放在构造函数中。这是我创建连接的代码:
QSignalMapper *signalMapper1 = new QSignalMapper(this);
signalMapper1->setMapping(ui.courseNameLineEdit,0);
QObject::connect(ui.courseNameLineEdit,SIGNAL(returnPressed()),signalMapper1, SLOT(map()));
QObject::connect(signalMapper1, SIGNAL(mapped(int)),this, SLOT(step1SaveAction(int)));