Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |

# User Interface Compiler (uic)

This page documents the User Interface Compiler for the Qt GUI toolkit. The uic reads an XML format user interface definition (.ui) file as generated by Qt Designer and creates corresponding C++ header or source files. It can also generate an image file to embed raw image data in C++ source code.

Usage:

        uic  [options] [mode] <uifile>

## Options

### File Generation Options

Generate declaration:

        uic  [options]  <uifile>

Generate implementation:

        uic  [options] -impl <headerfile> <uifile>

- <headerfile> - name of the declaration file

Generate image collection:

        uic  [options] -embed <project> <image1> <image2> <image3> ...

- <project> - project name
- <image[1..n]> - image files

or

        uic  [options] -embed <project> -f <file containing list of images>

For convenience, uic can also generate declaration or implementation stubs for subclasses.

Generate subclass declaration:

        uic  [options] -subdecl <subclassname> <baseclassheaderfile> <uifile>

- <subclassname> - name of the subclass to generate
- <baseclassheaderfile> - declaration file of the baseclass

Generate subclass implementation:

        uic  [options] -subimpl <subclassname> <subclassheaderfile> <uifile>

- <subclassname> - name of the subclass to generate
- <subclassheaderfile> - declaration file of the subclass

### General Options

- `-o file` - write output to 'file' rather than to stdout.
- `-pch file` - Add #include "file" as the first statement in the implementation.
- `-nofwd` - omit forward declarations of custom classes in the generated header file. This is necessary if typedef classes are used.
- `-tr func` - use `func(sourceText, comment)` rather than trUtf8(sourceText, comment) for internationalization.
- `-L path` - Additional plugin search path.
- `-version` - Display the version of uic and exit.

## Usage

uic is almost always invoked by `make (1)`, rather than by hand.

Here are useful makefile rules if you only use GNU make:

            %.h: %.ui
                uic $< -o $@

            %.cpp: %.ui
                uic -impl $*.h $< -o $@

If you want to write portably, you can use individual rules of the following form:

            NAME.h: NAME.ui
                uic $< -o $@

            NAME.cpp: NAME.ui
                uic -impl $*.h $< -o $@

You must also remember to add `NAME.cpp` to your SOURCES (substitute your favorite name) variable and `NAME.o` to your OBJECTS variable.

(While we prefer to name our C++ source files .cpp, the uic doesn't care, so you can use .C, .cc, .CC, .cxx or even .c++ if you prefer.)