PDA

View Full Version : Checkbox save state.



Project25
14th December 2009, 23:31
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.


int main(int argc, char **argv)
{
QApplication app(argc, argv);

QWidget *pWidget = new QWidget();
pWidget->setFixedSize(220,150);

QComboBox* pComboBox = new QComboBox(pWidget);
pComboBox->addItems((QStringList() << "Test1"<<"Test2" << "Test3"));
QCheckBox* pCheckBox = new QCheckBox(pWidget);
pCheckBox->setChecked(true);

QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(pComboBox);
layout->addWidget(pCheckBox);
pWidget->setLayout(layout);
pWidget->show();
return app.exec();
}