Google

Chapter 9. The File Format Of .ui Files

Qt Designer's .ui files are a form of XML files. They follow a certain Document Type Definition (DTD), which is called UI. This chapter is not a formal specification of the DTD but a verbal description of how these files are constructed and what syntax they follow. This information will enable you to quickly change things directly in the files without having to start Qt Designer or even mass-manipulate .ui files with Perl scripts or other text manipulation tools. It is also conceivable to have a tool that extracts translatable strings from the .ui files, even though Qt has other methods for this that apply at a later stage (namely, on the generated source files).

Each .ui file consists of the following parts in this order:

  1. The literal string <!DOCTYPE UI><UI>

  2. Header elements

  3. Exactly one <widget> element that describes the top-level widget of the form

  4. Optionally, a collection of pixmaps in an <images> element

  5. Optionally, a section that describes the used custom widgets

  6. Optionally, a section on the defined connections and slots

  7. Optionally, a section on the tab-chain

  8. The literal string </UI>

We'll now cover all these parts one by one.

Header Elements

The header elements describe general information about the form. All of them are optional.

<class>

If this element is specified, its content is used as the name of the class that uic generates. Otherwise, the name of the top-level widget is used.

<comment>

If you have entered a comment in the Form Settings dialog, this is where it will appear. It will not appear in the generated source code, however.

<author>

This element contains information about the author of the form. This information will not appear in the generated source code, however.

<include>

If you have specified additional include files in the Form Settings dialog, this is where they will appear.

<pixmapfunction>

If you have specified a function for loading pixmaps, this element names it. This also means that the images are not listed in the <images> element described later in this chapter.