<h2align="center">Reference: The .ui File Format</h2>
<p><em>TQt Designer</em> stores forms in <tt>.ui</tt> 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 <tt>.ui</tt> parsers so that they can read and modify <tt>.ui</tt> files programatically.</p>
<p>One way to parse a <tt>.ui</tt> file is to use TQt and the <ahref="tqdomdocument.html">TQDomDocument</a> class; this is how <em>TQt Designer</em> does it: see the <tt>uilib/tqwidgetfactory.h</tt> and <tt>uilib/tqwidgetfactory.cpp</tt> source files. For information on dynamically loading and running <tt>.ui</tt> files see <ahref="designer-manual-6.html#2-3-2">Loading and Executing a Dynamic Dialog</a>.</p>
<li><p><ahref="designer-manual-16.html#1-9">functions</a> - function declarations</p>
<li><p><ahref="designer-manual-16.html#1-10">images</a> - embedded images: only for <tt>.ui</tt> files than include embedded images; images are normally stored in a separate <tt>images</tt> directory</p>
<li><p><ahref="designer-manual-16.html#1-11">includes</a> - include files</p>
<li><p><ahref="designer-manual-16.html#1-12">layoutdefaults</a> - default values for layout attributes</p>
<li><p><ahref="designer-manual-16.html#1-13">layoutfunctions</a> - dynamic default values for layout attributes</p>
<li><p><ahref="designer-manual-16.html#1-15">pixmapfunction</a> - the name of the function to use for retrieving pixmaps if neither embedded nor external pixmaps are being used</p>
<li><p><ahref="designer-manual-16.html#1-16">pixmapinproject</a> - an element whose presence ndicates that the pixmaps are handled by the <tt>.pro</tt> file</p>
<li><p><ahref="designer-manual-16.html#1-17">signals</a> - signal declarations</p>
<li><p><ahref="designer-manual-16.html#1-21">variables</a> - class variables</p>
<li><p><ahref="designer-manual-16.html#1-22">widget</a> - the form itself; this element may contain other elements, including other <tt>widget</tt> elements</p>
<p>The <tt>actions</tt> element contains one or more <tt>action</tt> elements. Each <tt>action</tt> element contains one or more properties. Each property has a <tt>name</tt> attribute, and a single value which is contained within a <ahref="designer-manual-16.html#datatype">datatype</a> element.</p>
<p>This element is used to record the signals and slots connections in the form.</p>
<p>The <tt>connections</tt> element contains one or more <tt>connection</tt> elements and one or more <tt>slot</tt> elements. Each <tt>connection</tt> element identifies the signaling object and its signal, and the receiving object and its slot.</p>
<p><em>TQt Designer</em> can operate with custom widgets. A custom widget is represented in a <tt>.ui</tt> file using the <tt><customwidget></tt> element.</p>
<p>Note that these are the 'old-style' custom widgets that show up on the form as grey rectangles. Use plugins to seamlessly integrate your custom widgets into <em>TQt Designer</em> -- see <ahref="designer-manual-7.html#2">Creating Custom Widgets with Plugins</a>.</p>
<p>Each custom widget has a class name and a header file. They also have a size hint and size policy. A pixmap can be specified; this is displayed on a <em>TQt Designer</em> toolbar button which the user can use to create an instance of the custom widget. Custom widgets usually emit signals, and these are listed. The name and type of any properties that the widget has are also included.</p>
<p>If you have a class that requires some Windows-specific export macro, e.g. for classes in a DLL that need to be declared like this: <tt>class win_specific_declaration_goes_here Class</tt>, you can use the <tt><exportmacro></tt> tag. (In standard TQt we use the <tt>TQ_EXPORT</tt> macro, e.g. <tt>class TQ_EXPORT TQWidget</tt>.) If you use this tag you must also:</p>
<oltype=1><li><p><ahref="designer-manual-16.html#1-11">include</a> the file which contains the macro definition;</p>
<li><p>add the export macro to the form -- this is achieved by entering the macro's name in the 'export macro' sub-property of the form's name property.</p>
</ol><p>Following these steps will ensure that <ahref="uic.html">uic</a> will create the correct <tt>class YOUR_MACRO Form</tt> declarations.</p>
<p>It is sometimes necessary to forward declare classes, particularly if code is being written in <tt>.ui.h</tt> files within <em>TQt Designer</em>. Each forward declaration is listed as it should appear in the generated C++ code.</p>
<p>The <tt>functions</tt> element contains a list of functions. Functions are standard C++ functions. It is possible to specify various attributes to create a function's signature, for example:</p>
<ul><li><p>access: <tt>private</tt>, <tt>protected</tt> or <tt>public</tt>. Default: <tt>public</tt></p>
<li><p>returnType: the return datatype of the function. Default: <tt>void</tt></p>
<li><p>specifier: <tt>non virtual</tt>, <tt>virtual</tt> or <tt>pure virtual</tt>. Default: <tt>virtual</tt></p>
<li><p>language: specifies the programming language. Default: <tt>C++</tt></p>
<p>Images are normally stored in their own files and associated with forms using project files. This has the advantage that images can be shared across any number of forms in a project, and between projects.</p>
<p>In some cases it may be desireable to store image data directly in a form, and the <tt><image></tt> tag allows for this.</p>
<p>It is possible to store images in both PNG and XPM formats, although in practice only XPM is recommended because of bugs in some PNG libraries. See the <tt>saveImageData</tt> function in <tt>resource.cpp</tt> to see how the image data is encoded.</p>
<p>It is sometimes necessary to <tt>#include</tt> header files in a <tt>.ui</tt> file. Header files may be 'local', i.e. relative to the project's directory, or 'global', i.e. part of TQt or the compilers standard libraries. Header files are declared in the implementation wherever possible, although sometimes it is necessary to declare them in the declaration (header) file.</p>
<p><em>TQt Designer</em> automatically adds <tt><include></tt> tags for a <tt>.ui</tt>'s <tt>.ui.h</tt> file.</p>
<p>Applications that use <ahref="ntqmainwindow.html">TQMainWindow</a> often have a menubar. The menubar has a name property and one or more popup menu items. Each menu item has one or more actions and optionally separators.</p>
<p>Images are normally included by listing their filenames in project files. Images can also be included inline using the <ahref="designer-manual-16.html#1-10">images</a> tag. Another way of dealing with images is to specify a function name. This function will be called, with the name (or 'key') of the relevant image, and is responsible for loading the appropriate image. To specify such a function the <tt><pixmapfunction></tt> tag is used.</p>
<p>Most applications store their images as separate files listed in the application's project file. This can be signified by including the <tt><pixmapinproject></tt> tag.</p>
<p>Tabstops indicate the widgets that get the focus as the user tabs through the form. The <tt><tabstops></tt> tag contains a list of tabstops, in order, each of which holds the name of a widget.</p>
<p>Forms that have toolbars (dock windows) use the <tt><toolbars></tt> tag to hold the details. These forms are normally <ahref="ntqmainwindow.html">TQMainWindow</a>s (or subclasses). Each toolbar has a dock attribute which identifies which dock window the toolbar initially belongs to. They also have both name and label properties. Each toolbar button is represented by an action. Toolbars can also hold other widgets, in which case the <tt><toolbar></tt> tag includes appropriate <tt><widget></tt> tags which give the class, name and any non-default property values for the relevant widget.</p>
<p>Module variables are held in the <tt><variables></tt> tag. Variable type names often include < and >, which must be stored as entities. It is also possible to specify the access type - either <tt>public</tt>, <tt>protected</tt> or <tt>private</tt>. Default is <tt>protected</tt>.</p>
<p>Widgets are used at multiple levels within a <tt>.ui</tt> file. The whole form itself is a widget, and it contains other widgets, usually within the context of layouts such as hboxes, vboxes and grids.</p>
<p>Below is an example of a complete <tt>.ui</tt> file. The form itself is a <ahref="tqwidget.html">TQWidget</a> with various non-default properties set. This widget contains a single hbox, which also has some non-default properties, and which contains a single <ahref="ntqtextbrowser.html">TQTextBrowser</a> widget.</p>
<p><i> This tag is included for TQt 3.x beta backwards compatibility, and should not be used. Use <ahref="designer-manual-16.html#1-8">forwards</a> instead. </i></p>
<p><i> This tag is included for TQt 2.x beta backwards compatibility, and should not be used. Use <ahref="designer-manual-16.html#1-11">includes</a> instead. </i></p>
<p><i> This tag is included for TQt 3.x beta backwards compatibility, and should not be used. Use <ahref="designer-manual-16.html#1-21">variables</a> instead. </i></p>
<aname="color"></a><ul><li><p><tt>bool</tt> - a boolean value (0 or 1), e.g. <tt><bool>1</bool></tt></p>
<li><p><tt>color</tt> - a color, e.g. <tt><color><red>192</red><green>0</green><blue>255</blue></color></tt></p>
<li><p><tt>cstring</tt> - a C string value (8-bit), e.g. <tt><cstring>Some text</cstring></tt></p>
<li><p><tt>cursor</tt> - an integer which indicates the cursor type, e.g. <tt><cursor>4</cursor></tt>. The valid integers for the cursor type are:</p>
<ul><li><p>0 - ArrowCursor</p>
<li><p>1 - UpArrowCursor</p>
<li><p>2 - CrossCursor</p>
<li><p>3 - WaitCursor</p>
<li><p>4 - IbeamCursor</p>
<li><p>5 - SizeVerCursor</p>
<li><p>6 - SizeHorCursor</p>
<li><p>7 - SizeBDiagCursor</p>
<li><p>8 - SizeFDiagCursor</p>
<li><p>9 - SizeAllCursor</p>
<li><p>10 - BlankCursor</p>
<li><p>11 - SplitVCursor</p>
<li><p>12 - SplitHCursor</p>
<li><p>13 - PointingHandCursor</p>
<li><p>14 - ForbiddenCursor</p>
</ul><li><p><tt>enum</tt> - an enum name, e.g. <tt><enum>StrongFocus</enum></tt></p>
<li><p><tt>font</tt> - a font description, e.g.</p>
<pre>
<font>
<family>Helvetica</family>
<pointsize>16</pointsize>
<weight>50</weight>
<italic>1</italic>
<underline>0</underline>
<strikeout>0</strikeout>
</font>
</pre>
<li><p><tt>iconset</tt> - an iconset (see <tt>pixmap</tt>), e.g. <tt><iconset>filenew</iconset></tt></p>
<li><p><tt>number</tt> - an integer with an optional sign, e.g. <tt><number>947</number></tt></p>
<li><p><tt>pixmap</tt> - a pixmap, normally the name or "key" of the pixmap; the name is used if pixmaps are stored in the project, the key is used if a user defined function is used to access the pixmap. It is also possible for pixmaps to be included inline. Example: <tt><pixmap>chair</pixmap></tt></p>
<li><p><tt>point</tt> - a point, e.g. <tt><point><x>15</x><y>95</y></point></tt></p>
<li><p><tt>rect</tt> - a rectangle, e.g.</p>
<pre>
<rect>
<x>20</x>
<y>35</y>
<width>225</width>
<height>45</height>
</rect>
</pre>
<li><p><tt>set</tt> - a list of names separated by |'s, e.g. <tt><set>AlignLeft|AlignTop</set></tt></p>
<li><p><tt>size</tt> - a size, e.g. <tt><size><width>150</width><height>105</height></size></tt></p>
<li><p><tt>sizepolicy</tt> - an integer which indicates the size type, e.g. <tt><hsizetype>5</hsizetype><vsizetype>4</vsizetype></tt>. The valid integers for the size type are:</p>
<ul><li><p>0 - Fixed</p>
<li><p>1 - Minimum</p>
<li><p>3 - MinimumExpanding</p>
<li><p>4 - Maximum</p>
<li><p>5 - Preferred</p>
<li><p>7 - Expanding</p>
</ul><li><p><tt>string</tt> - a Unicode string value (in UTF8), e.g. <tt><string>Some text</string></tt></p>