how to check the output of the QCombobox box
-
@milhao
I assume you drag and drop a comboBox in you're ui.file and then set the items, if this is you're case you can try :-Go to the ui.file , right click on the comboBox , GoToSlot -> select on CurrentTextChanged, then , in the method that is created automathically you write this:
void MainWindow::on_comboBox_1_currentTextChanged(const QString &arg1) { if(ui->comboBox_1->currentText()=="elf"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); }else if(ui->comboBox_1->currentText()=="human"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); } }
-
@JonB how would I use this corresponding Changed() signal.
And another one, what is the return of QComboBox::currentIndex() or QComboBox::currentText(), because I want to get the word elf and compare it with the return of QComboBox to know if it is chosen -
-
@milhao
I assume you drag and drop a comboBox in you're ui.file and then set the items, if this is you're case you can try :-Go to the ui.file , right click on the comboBox , GoToSlot -> select on CurrentTextChanged, then , in the method that is created automathically you write this:
void MainWindow::on_comboBox_1_currentTextChanged(const QString &arg1) { if(ui->comboBox_1->currentText()=="elf"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); }else if(ui->comboBox_1->currentText()=="human"){ qDebug()<<" you have chosen --> "<<ui->comboBox_1->currentText(); } }