I have StackedWidget with 3 pages, every page contain 3 lineEdit, now at every page I pass, I want to save the content of this 3 lineEdit into a variable to be able later handle it.
I have this piece of code:
connect(ui->stackedWidget, SIGNAL(currentChanged(int)), this, SLOT(getInputs(int)));
And the slot:
void ConfSetup::getInputs(int index)
{
QString para;
switch(index)
{
case 1:
ui->backButton0->setEnabled(false);
break;
case 2:
inputs << ui->serverEdit->text();
inputs << ui->portEdit->text();
break;
case 3:
inputs << ui->userDbEdit->text();
inputs << ui->passwordDbEdit->text();
break;
case 6:
foreach(para, inputs)
ui->comboBox->addItem(para);
//ui->lineEdit->setText(QString::number(para.length()));
break;
default:
ui->backButton0->setEnabled(true);
break;
}
}
The comboBox widget should now contains 4 values, but rather then it contains a blank text, also para.length() return 0 in lineEdit widget.
A friend tell me that I am filling the
inputsvariable at time I change the index page, witch mean of course thelineEditwidgets are empty at that time. The solution is very simple, first, I avoidgetInputs(int )slot, and in replacement I make this: