As its name implies, the widget element describes one widget. At the top level of the .ui file, there must be exactly one such element for the top-level widget of the form, but this element can in turn contain other <widget> elements.
A <widget> element can have the following subelements:
There must be exactly one such element that describes the C++ class of the widget (like QWidget).
There can be any number of such elements that describe the properties of the widget that differ from the default. See the next section for a description of how <property> elements should look.
There can be any number of such elements that describe the attributes of the widget. Attributes are like properties, but are not defined in the widget and need to be treated specially. This element has the same syntax as the <property> element.
There can be any number of such elements that describe the items of this widget if the widget can contain items (like list boxes or icon views). See the section called The <item> Element for the exact syntax of this item.
There can be any number of such elements that describe the columns of this widget if the widget is a list view. See the section called The <column> Element for the exact syntax of this item.
Child widgets can be specified in one of four ways:
If the widget does not use any layout management, then the children are directly specified as <widget> elements.
If the widget uses a horizontal box layout as its outermost layout, then exactly one <hbox> is specified, which in turn specifies the child widgets. See the section called The <hbox> Element for the exact syntax of this element.
If the widget uses a vertical box layout as its outermost layout, then exactly one <vbox> is specified, which in turn specifies the child widgets. See the section called The <vbox> Element for the exact syntax of this element.
If the widget uses a grid layout as its outermost layout, then exactly one <grid> is specified, which in turn specifies the child widgets. See the section called The <grid> Element for the exact syntax of this element.
This element describes a property of a widget or a layout. Each property has as its first child a <name> element that describes the name of the property (like geometry) and as its second child an element whose name describes the type and whose contents describe the value of the property. Table 9-1 lists the possible type names together with a description of their values.
Table 9-1. Property Types
Element Name | Type | Description of the Value | Example | |
---|---|---|---|---|
string | Any Unicode string value (saved in UTF-8) | String | <string>Some Text</string> | |
cstring | Any c-string (8-bit) value | CString | <string>Some Text</string> | |
bool | Any boolean value | Bool (1|0) | <bool>1</bool> | |
number | Any signed numerical value | Integer | <number>-4</number> | |
number | Any unsigned numerical value | Unsigned integer | <number>1</number> | |
enum | Enum key | String | <enum>StrongFocus</enum> | |
set | Set (OR'd integers) | StringList joined with '|' | <set>AlignLeft|AlignTop|WordWrap</set> | |
rect | Rectangles |
<x>Integer</x> |
<rect> |
|
point | Points (coordinates) |
<x>Integer</x> |
<point> |
|
size | Sizes |
<width>Integer</width> |
<size> |
|
font | Font description |
<family>String</family> |
<font> |
|
color | Color description |
<red>Integer</red> |
<color> |
|
pixmap/image/imageset | Pixmap | Depending on whether images are saved inline or not (see earlier in the "Header Elements" section), this element looks different:
|
<pixmap>image1</pixmap> | |
sizepolicy | SizePolicy (saved as int) |
<hsizetype>SizeType</hsizetype> SizeType is saved as int and can be one of the following:
|
<hsizetype>1</hsizetype> |
|
palette | Palette |
<palette> <active> <color> rgb of Foreground </color> <color> rgb of Button </color> <color> rgb of Light </color> <color> rgb of Midlight </color> <color> rgb of Dark </color> <color> rgb of Mid </color> <color> rgb of Text </color> <color> rgb of BrightText </color> <color> rgb of ButtonText </color> <color> rgb of Base </color> <color> rgb of Background </color> <color> rgb of Shadow </color> <color> rgb of Highlight </color> <color> rgb of HighlightText </color> </active> <disabled> ColorGroup of disabled palette </disabled> <inactive> ColorGroup of inactive palette </inactive> </palette> |
<palette> <active> <color> <red>0</red> <green>0</green> <blue>0</blue> </color> <color> <red>170</red> <green>170</green> <blue>255</blue> </color> <color> <red>255</red> <green>255</green> <blue>255</blue> </color> <color> <red>212</red> <green>212</green> <blue>255</blue> </color> <color> <red>85</red> <green>85</green> <blue>127</blue> </color> <color> <red>113</red> <green>113</green> <blue>170</blue> </color> <color> <red>0</red> <green>0</green> <blue>0</blue> </color> <color> <red>255</red> <green>255</green> <blue>255</blue> </color> <color> <red>0</red> <green>0</green> <blue>0</blue> </color> <color> <red>255</red> <green>255</green> <blue>255</blue> </color> <color> <red>218</red> <green>218</green> <blue>218</blue> </color> <color> <red>0</red> <green>0</green> <blue>0</blue> </color> <color> <red>90</red> <green>36</green> <blue>0</blue> </color> <color> <red>255</red> <green>255</green> <blue>255</blue> </color> </active> <disabled> ...... </disabled> <inactive> ...... </inactive> </palette> |
|
cursor | Cursor saved as int |
The following int values are defined for cursor:
|
<cursor>5</cursor> |
This element describes a layout that arranges its children from left to right. It must be a child of a <widget> element. This widget is then normally a container widget (e.g., a QGroupBox) or a temporary QLayoutWidget. The following child elements are defined:
There can be any number of these elements, which describe a property of the layout.
There can be any number of these elements, which describe a child widget that is managed by the layout.
There can be any number of these elements, which describe a spacer in the layout (see the section called The <spacer> Element ).
This element describes a layout that arranges its children from top to bottom. It must be a child of a <widget> element. This widget is then normally a container widget (e.g., a QGroupBox) or a temporary QLayoutWidget. The following child elements are defined:
There can be any number of these elements, which describe a property of the layout.
There can be any number of these elements, which describe a child widget that is managed by the layout.
There can be any number of these elements, which describe a spacer in the layout (see the section called The <spacer> Element ).
This element describes a layout that arranges its children in a grid. It must be a child of a <widget> element. This widget is then normally a container widget (e.g., a QGroupBox) or a temporary QLayoutWidget. The following child elements are defined:
There can be any number of these elements, which describe a property of the layout.
There can be any number of these elements, which describe a child widget that is managed by the layout.
Besides the elements ordinarily defined as subelements of <widget>, there can be <row> and <col> elements, which specify the position of the widget in the grid. These elements themselves can have one or both of the attributes rowspan and colspan, which specify the number of rows and columns the cell should cover. The default is 1.
There can be any number of these elements, which describe a spacer in the layout (see the next section).
Besides the elements ordinarily defined as subelements of <spacer>, there can be <row> and <col> elements, which specify the position of the widget in the grid. These elements themselves can have one or both of the attributes rowspan and colspan, which specify the number of rows and columns the cell should cover. The default is 1.
This element describes a spacer item inside a layout. It has four properties:
This property, of the type string, describes the name of the item.
This property, of the type enum with the valid values Horizontal and Vertical, describes the orientation of the item.
This property, of the type enum, describes how the item expands in its direction. See the Qt Reference Documentation for size policies for more information.
This property, of the type rect, describes the geometry of the spacer, which is normally useful only for fixed spacing.
This element describes an item of a widget if this widget can contain items (like list boxes, icon views, etc.). The item element contains exactly one child element that describes the item. This child element is a <property> element. Valid property names are text and pixmap, depending on where to insert the item.
As list views can hold a tree of items, the <item> element can contain other <item> elements, which are then child items. Also, as list views can have many columns, an <item> element contains a text and a pixmap property for each column. The columns of a list view are described with a <column> element (see the next section).
This element describes the columns of a list view widget. A list view can contain multiple column elements. A column element contains the following properties, which are all optional:
This property, of type string, contains the column label.
This property, of type pixmap, contains the column pixmap.
This property, of type bool, describes whether the column may be resized by the user.
This property, of type bool, describes whether the column may be moved by the user.