You have to create a slot and connect the clicked signal from both the buttons to it.
in the slot you can enable the third button
this needs to be in the .h file
private slots:
void aButtonClicked();
private slots:
void aButtonClicked();
To copy to clipboard, switch view to plain text mode
this goes in the .cpp file
Class::Class() //this is the constructor it may look different than the one you have
{
connect(ui->btnOne,SIGNAL(clicked()),this,SLOT(aButtonClicked()));
connect(ui->btnTwo,SIGNAL(clicked()),this,SLOT(aButtonClicked()));
}
void Class::aButtonClicked() //change "class" to your class its name
{
ui->btnThree->setEnabled(true);
}
Class::Class() //this is the constructor it may look different than the one you have
{
connect(ui->btnOne,SIGNAL(clicked()),this,SLOT(aButtonClicked()));
connect(ui->btnTwo,SIGNAL(clicked()),this,SLOT(aButtonClicked()));
}
void Class::aButtonClicked() //change "class" to your class its name
{
ui->btnThree->setEnabled(true);
}
To copy to clipboard, switch view to plain text mode
this piece of code enables the third button if one of the two buttons has been clicked
if both of the buttons have to be clicked before enabeling the third then it needs some extra code
this needs to be in the .h file
private slots:
void buttonOneClicked();
void buttonTwoClicked();
private:
void checkButton();
bool chkBtnOne,chkBtnTwo;
private slots:
void buttonOneClicked();
void buttonTwoClicked();
private:
void checkButton();
bool chkBtnOne,chkBtnTwo;
To copy to clipboard, switch view to plain text mode
this goes in the .cpp file
Class::Class() //this is the constructor it may look different than the one you have
{
chkBtnOne = chkBtnTwo = false;
connect(ui->btnOne,SIGNAL(clicked()),this,SLOT(buttonOneClicked()));
connect(ui->btnTwo,SIGNAL(clicked()),this,SLOT(buttonTwoClicked()));
}
void Class::buttonOneClicked() //change "class" to your class its name
{
chkBtnOne = true;
checkButton();
}
void Class::buttonTwoClicked() //change "class" to your class its name
{
chkBtnTwo = true;
checkButton();
}
void Class::checkButton()
{
if (chkBtnOne && chkBtnTwo)
ui->btnThree->setEnabled(true);
}
Class::Class() //this is the constructor it may look different than the one you have
{
chkBtnOne = chkBtnTwo = false;
connect(ui->btnOne,SIGNAL(clicked()),this,SLOT(buttonOneClicked()));
connect(ui->btnTwo,SIGNAL(clicked()),this,SLOT(buttonTwoClicked()));
}
void Class::buttonOneClicked() //change "class" to your class its name
{
chkBtnOne = true;
checkButton();
}
void Class::buttonTwoClicked() //change "class" to your class its name
{
chkBtnTwo = true;
checkButton();
}
void Class::checkButton()
{
if (chkBtnOne && chkBtnTwo)
ui->btnThree->setEnabled(true);
}
To copy to clipboard, switch view to plain text mode
Bookmarks