I have Qcheckbox and combobox in one horizontal layout. How do I save the state of QCheckbox when I change the current index of combobox? For instance if I select first time in comboBox and I checked the checkbox and then I select second item "Test2" and I unchecked the checkbox. Now I select the first item again and my checbox is unchecked (that should be checked). How would I save the state of checkbox before I move to next item in comboBox.

Qt Code:
  1. int main(int argc, char **argv)
  2. {
  3. QApplication app(argc, argv);
  4.  
  5. QWidget *pWidget = new QWidget();
  6. pWidget->setFixedSize(220,150);
  7.  
  8. QComboBox* pComboBox = new QComboBox(pWidget);
  9. pComboBox->addItems((QStringList() << "Test1"<<"Test2" << "Test3"));
  10. QCheckBox* pCheckBox = new QCheckBox(pWidget);
  11. pCheckBox->setChecked(true);
  12.  
  13. QHBoxLayout *layout = new QHBoxLayout;
  14. layout->addWidget(pComboBox);
  15. layout->addWidget(pCheckBox);
  16. pWidget->setLayout(layout);
  17. pWidget->show();
  18. return app.exec();
  19. }
To copy to clipboard, switch view to plain text mode