# KConfigDialog

If you need a configuration dialog for your QtWidgets application, use KConfigDialog.

KConfigDialog handles the enabling and disabling of buttons, creation of the dialog, and deletion of the widgets. Because of KConfigDialogManager, this class also manages: restoring the settings, resetting them to the default values, and saving them.

This requires that the names of the widgets corresponding to configuration entries have to have the same name plus an additional "kcfg\_" prefix. For example the widget named "kcfg\_MyOption" would be associated with the configuration entry "MyOption".

Here is an example usage of KConfigDialog:

```
void KCoolApp::showSettings(){
    if (KConfigDialog::showDialog(QStringLiteral("settings"))) {
      return;
    }
    KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), MySettings::self());
    dialog->setFaceType(KPageDialog::List);
    dialog->addPage(new General(0, "General"), i18n("General"));
    dialog->addPage(new Appearance(0, "Style"), i18n("Appearance"));
    connect(dialog, &KConfigDialog::settingsChanged, mainWidget, &Bar::loadSettings);
    connect(dialog, &KConfigDialog::settingsChanged, this, &Foo::loadSettings);
    dialog->show();
}
```

Other than the above code, each class that has settings in the dialog should have a loadSettings() type slot to read settings and perform any necessary changes.

For dialog appearance options (like buttons, default button, ...) please see [KPageDialog](https://api.kde.org/frameworks/kwidgetsaddons/html/classKPageDialog.html).

For more information, consult the [api documentation of KConfigDialog](https://api.kde.org/frameworks/kconfigwidgets/html/classKConfigDialog.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.novaflowos.com/start/kde-developer-platform/readme/features/configuration/configdialog.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
