Solved connect button to stackWidget and radioButton to comboBox
-
I want to connect pushButton to stackWidget index I used
connect(ui->user, SIGNAL(clicked(bool)), ui->stackedWidget,SLOT(setCurrentIndex(int)));
It is not complete and it does not work
And to connect radioButton to the comboBox (if radioButton was hit, comboBox would be enabled) I used
connect(ui->radioButton_co,SIGNAL(clicked()),ui->comboBox_co,SLOT(setEnabled(bool)));
It also not complete and it does not work
How should I do this without defining any function? -
Hi
connect(ui->user, SIGNAL(clicked(bool)), ui->stackedWidget,SLOT(setCurrentIndex(int)));Can never work as clicked can maximum send a bool and
setCurrentIndex expects and int that tells what index to go to.What do u try to make it do with one button ?
for combobox
connect(ui->radioButton_co,SIGNAL(clicked(bool)),ui->comboBox_co,SLOT(setEnabled(bool)));
should work.
But not sure it works as you want as radio buttons normally comes in a group.
If you just have 1 radiobutton, its not possible to unselect it again.If just to enable combo, then QCheckbox might be better.
-
I did this to change the page
void Healthy::on_user_clicked() { ui->stackedWidget->setCurrentIndex(5); }
But I want to use a connection to do this
comboBox is disabled for the first timeui->comboBox_co->setDisabled(1);
I used QCheckBox, but when checking QCheckBox ,the comboBox is not enabled
connect(ui->checkBox_co,SIGNAL(clicked()),ui->comboBox_co,SLOT(setEnabled(bool)));
when I run the program I get this
QObject::connect: Incompatible sender/receiver arguments QCheckBox::clicked() --> QComboBox::setEnabled(bool)
-
Hi
But dont u need to slots like
nextPage and prevPage ?
to go back and forth. You can use lambdas for compact design.you forgot the parameter type
connect(ui->checkBox_co,SIGNAL(clicked(bool)),ui->comboBox_co,SLOT(setEnabled(bool)));
also connects return true/false so u can spot when you have made error. -
connect(ui->checkBox_co,SIGNAL(clicked(bool)),ui->comboBox_co,SLOT(setEnabled(bool)));
And I use this for change page
connect(ui->user, &QAbstractButton::clicked, [=](bool b){ui->stackedWidget->setCurrentIndex(5);});
it work thanks to u
-
@isan
Ok super.
So you just need button to go exact page. and not navigate back and forth. -
@mrjj said in connect button to stackWidget and radioButton to comboBox:
So you just need button to go exact page. and not navigate back and forth.
at this time ,yes