使用currentIndex()或者currentText()
void Widget::calc()
{
int first = ui->firstLineEdit->text().toInt();
int second = ui->secondLineEdit->text().toInt();
int result;
switch(ui->comboBox->currentIndex())
{
case 0:
result = first + second;
ui->resultLineEdit->setText(QString::number(result));
break;
case 1:
result = first - second;
ui->resultLineEdit->setText(QString::number(result));
break;
case 2:
result = first * second;
ui->resultLineEdit->setText(QString::number(result));
break;
case 3:
if(second != 0)
{
result = first / second;
ui->resultLineEdit->setText(QString::number(result));
}
break;
default:break;
}
}