Question: How do I keep the value of a user entered QlineEdit or a checkbox that is checked to keep it's state even after program is closed, in this way, the user can access the contents of that checkbox or lineEdit the next time he starts the program.

Answer: 
**Qt** has a dedicated solution for that, which is [`QSettings`](http://qt-project.org/doc/qt-4.8/qsettings.html):

```
void MainWindow::saveSettings()
{
    QSettings settings("settings.set", QSettings::NativeFormat);

    // save value from QLineEdit
    QString text = lineEdit->text();
    settings.setValue("text", text);

    // save value of QCheckBox
    settings.setValue("box", (int)checkBox->checkState());
}

void MainWindow::loadSettings()
{
    QSettings settings("settings.set", QSettings::NativeFormat);

    // restore value of QLineEdit
    QString text = settings.value("text", "").toString();
    lineEdit->setText(text);

    // restore value of QCheckBox
    checkBox->setCheckState((Qt::CheckState)settings.value("box", 0).toInt());
}

```
Store the value in a file and open the file on the next start of the program and read from it.