Using dialog files

In this part we use dialog files to layout dialogs seperately from the source code.

To download the code for this tutorial, fetch it from the git-repository by issuing:

git clone git://

Then you can follow this part by having a look at the tutorials firststeps/02 folder.

What is a dialog file?

Dialog files store information about layout and structure of window content. It is the easiest way of creating content. It frees from programming a fixed dialog structure and lets designers change the face of the dialog, without programming a single line.

The first dialog

The first dialog resembles the simple "Hello world!" from the first example. The following content should be placed inside a file named dialog.xml.

    <rootwindow w="100%" h="100%" margin="0" alignment="center" 
                border.thickness="0" bgcolor="#00000000" opacity="255">

        <label name="label1" text="Hello World" alignment="center"
               bgcolor="#00000000" color="#999999ff"
     "DejaVuSansMono.ttf" font.size="18"/>


The structure is pretty simple. A <mmsdialog> spans a <rootwindow> which contains only one label as a child item.

Load and show the dialog

To load the dialog into a window the MMSDialogManager is used. As for now we continue to ignore themes for a while.

// load a window
MMSDialogManager dm;
MMSWindow *window = dm.loadDialog("./dialog.xml");

Like in the first tutorial, the window is showed by


Update dialog content

Most applications would want to update the text label with some other value. The text of the label is defined in the dialog.xml. How is the label accessed then? The label tag has an attribute name, with the value set to "label1". Using this name the label could be extracted by the dialog manager.

// extract the label
MMSLabel *label = (MMSLabel *)dm["label1"];	

// update the text
label->setText("updated hello world!");

This works for all kinds widgets. The naming of the widgets is important. Having two widgets with the same name results in an error. Only those widgets that should be acessible through the dialog manager should be named though.

The result should look like this: screenshot