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

[Prev: Reference: Windows] [Home]

Reference: The .ui File Format

Qt Designer stores forms in .ui files. These files use an XML format to represent form elements and their characteristics. This document provides an overview of the XML format used, and should provide enough information for developers to write their own .ui parsers so that they can read and modify .ui files programatically.

One way to parse a .ui file is to use Qt and the QDom class; this is how Qt Designer does it: see the resource.h and resource.cpp source files.

The doctype of a .ui file is simply "UI", so the doctype tag is:

<DOCTYPE "UI">

The root element is a "UI", which encloses the entire contents:

<UI version="3.0" stdsetdef="1">
...
</UI>

Within the UI entity, there may one or zero of the following element types:

The ordering of elements is arbitrary, although it is common for the class element to be first.

UI Elements

actions

This element is used to store the form's actions. It only occurs in QMainWindow forms.

The actions element contains one or more action elements. Each action element contains one or more properties. Each property has a name attribute, and a single value which is contained within a datatype element.

<actions>
    <action>
        <property name="name">
            <cstring>fileNewAction</cstring>
        </property>
        <property name="iconSet">
            <iconset>filenew</iconset>
        </property>
        <property name="text">
            <string>New</string>
        </property>
        <property name="menuText">
            <string>&amp;New</string>
        </property>
        <property name="accel">
            <number>4194382</number>
        </property>
    </action>
    ...
</actions>

author

This element is used to store the author's name as a simple string.

<author>Barney Rubble</author>

class

This element is used to store the form's class name as a simple string.

<class>InsuranceForm</class>

comment

This element is used to store comments, for example, copyright notices, as a simple string.

<comment>*********************************************************************
** Copyright (C) 2002 Trolltech AS.  All rights reserved.
**
** This file is part of Qt Designer.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
*********************************************************************</comment>
</comment>

connections

This element is used to record the signals and slots connections in the form.

The connections element contains one or more connection elements and one or more slot elements. Each connection element identifies the signaling object and its signal, and the receiving object and its slot. Each slot element provides a slot's signature.

<connections>
    ...
    <connection language="C++">
        <sender>alignActionGroup</sender>
        <signal>selected(QAction*)</signal>
        <receiver>EditorForm</receiver>
        <slot>changeAlignment(QAction*)</slot>
    </connection>
    ...
    <slot access="public" specifier="virtual" language="C++" 
	returnType="void">changeAlignment(QAction* align)</slot>
    ...
</connections>

customwidgets

exportmacro

### TODO

forwards

### TODO

images

### TODO

includes

### TODO

layoutdefaults

### TODO

menubar

### TODO

pixmapfunction

### TODO

pixmapinproject

### TODO

signals

### TODO

slots

### TODO

tabstops

### TODO

toolbars

### TODO

variables

### TODO

widget

### TODO

forward

### TODO

include

### TODO

variable

### TODO

Datatype Elements

Complex Datatype Elements

palette

This element holds colors for user interface elements for each color group. For example:

<palette>
  <active>
    <color> ... Foreground    ... </color>
    <color> ... Button        ... </color>
    <color> ... Light         ... </color>
    <color> ... Midlight      ... </color>
    <color> ... Dark	      ... </color>
    <color> ... Mid	      ... </color>
    <color> ... Text          ... </color>
    <color> ... BrightText    ... </color>
    <color> ... ButtonText    ... </color>
    <color> ... Base          ... </color>
    <color> ... Background    ... </color>
    <color> ... Shadow	      ... </color>
    <color> ... Highlight     ... </color>
    <color> ... HighlightText ... </color>
  </active>
  <disabled>
    <color><red>128</red><green>128</green><blue>128</blue></color>
    ...
    <color><red>255</red><green>255</green><blue>255</blue></color>
  </disabled>
  <inactive>
    <color><red>0</red><green>0</green><blue>0</blue></color>
    ...
    <color><red>255</red><green>255</green><blue>255</blue></color>
  </inactive>
</palette>

See color for the format of the <color> element.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.2