Now, this is a one which is baffling me,
Giving a short example of my sample GUI,
i. I have four labels in the mainwindow, label_1
, label_2
, label_3
, label_4
ii. I have a spinBox
, comboBox
and a pushButton
as well.
iii. The values in comboBox are - ITEM1, ITEM2, ITEM3, ITEM4.
iv. When user runs the program, he selects the value from spinBox
(1-4) and chooses the value from comboBox
. And on every press of pushButton
the labels text is changed,the logic for label text display
spinBox value = 1 and comboBox = ITEM1, label_1->setText("Item 1 in label1")
spinBox value = 1 and comboBox = ITEM2, label_1->setText("Item 2 in label1")
spinBox value = 1 and comboBox = ITEM3, label_1->setText("Item 3 in label1")
spinBox value = 1 and comboBox = ITEM4, label_1->setText("Item 4 in label1")
spinBox value = 2 and comboBox = ITEM1, label_2->setText("Item 1 in label2")
spinBox value = 2 and comboBox = ITEM2, label_2->setText("Item 2 in label2")
spinBox value = 2 and comboBox = ITEM3, label_2->setText("Item 3 in label2")
spinBox value = 2 and comboBox = ITEM4, label_2->setText("Item 4 in label2")
and so on.. .. .. for all the labels (i.e. label_2,label_3,label_4).
sample snippet,
void MainWindow::on_pushButton_clicked()
{
int spinValue;
QString comboText;
spinValue=ui->spinBox->value();
comboText=ui->comboBox->currentText();
if(spinValue==1)
{
if(comboText=="LABEL 1")
{
ui->label->setText("ITEM 1 in field 1");
}
else if(comboText=="LABEL 2")
{
ui->label->setText("ITEM 2 in field 1");
}.. .. .. .. .. .. ..
EDIT for better clarification, the user selects a value from spinbox (e.g. 1) selects a value from combobox (e.g. TEXT1) presses button; again selects a second value from spinbox (e.g. 2) selects a value from combobox (e.g. TEXT2) presses button etc... to populate data in all 4 labels.
i.e. in theory, the value in SpinBox is the label number.
Now, I want to ensure if the application restarts the state of the application should restore,
i.e. How to save the combination of SpinBox values and ComboBox values ???