# 11.2. Creating a New Dialog

After creating your project skelleton, you are provided a ready-to-run application, according to your preferences. As KDevelop provides the project types KDE and Qt application, the dialogeditor recognizes this and offers widget construction by the widgets that are provided by the used libraries. To save time, you already should have a design in mind that will do the intended actions. For information about widget design, see The KDevelop Programming Handbook.

To create a new dialog, select "New" from the "File"-menu or select "New" from the context menu in the "Dialogs" tab. The "New Dialog" menu appears where you have to give KDevelop the dialog-specific information about the baseclass and the source file names and destination.

## 11.2.1. Dialog Class

The dialog class you can select, is the class that is inherited by your new widget, which is technically represented by a class itself. Therefore, you have the following options:

1. QWidget: the base class for all user interaction widgets provided by Qt. Used for main views and top-level widgets.

2. QFrame: inherits QWidget and is used by numerous widgets as a base class. This is useful for widgets that already want to have a QFrame functionality in addition to QWidget methods.

3. Custom: inherits a custom class that has to be set in the "Custom Properties". This could be an already designed class provided by your project or the libraries.

4. QDialog: the base class for dialogs that you would inherit for user interaction like setting properties or changing values.

5. QTabDialog: inherits QDialog and provides a dialog with predefined buttons and a set of tabs, which you will provide by the widgets that you create.

Custom Properties

For the inheritance of a custom class as selected in the dialog class field, you have to specify the classname, which goes to "Custom Class". The dialogeditor uses this for the code-generation; therefore, you also have to insert the "Custom Header", where the header filename of the custom class has to be set.

## 11.2.2. Files

In the "Files" section, you have to enter the widget's specific information. This is the classname (which would be e.g. KColorSelectDlg for a dialog that allows selecting the color of a pen), the header, C++ and Data filenames. When inserting the Classname, the filenames are given by the dialogeditor, but you can as well change the filenames.

Now, what about the files ? When you are ready with constructing the widget visually, you will have to generate the files that contain the implementation for your widget. As this will be a class, the dialog will exist by the header file containing the classdeclaration, a C++ file containing the method implementation for your widget's methods and slots. The Data file is the file that will contain a function that is called by the constructor of your widget, the initDialog() method. The file itself shouldn't be changed as it will contain the generated code from the dialogeditor to create the widget on the screen. If you ever have to chage values, you should do this by the constructor or be sure that you won't change the dialog during the development process, as the Data file wil be overwritten each time the code is generated for your widget. The header and C++ file contain sections, where the dialogeditor writes; these are marked by comments. After file generation, you can change any values and settings outside these sections; otherwise your changees will get lost by the next code-creation.

## 11.2.3. Location

For generating the widget's sources, the dialogeditor needs to know the location where these will go. The default value for the output directory is the current project subdirectory containing the sources already present.

After pressing "OK", your default values are generated and an empty Widget constructor is opened. Then you are ready to go for creating your own widget. Mind that the dialogeditor currently only supports static widgets without geometry management. If you're about to use geometry management for your widgets, you should make yourself accustomed with the classes that Qt provides for this, create a new class with the classgenerator and write your widget by hand. For more information, see The KDevelop Programming Handbook.