Qt Designer 的 UI 文件格式

The UI 文件格式用于 Qt Designer 的描述是通过 XML schema presented below, which we include for your convenience. Be aware that the format may change in future Qt releases.

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
        <xs:element name="ui" type="UI"/>
        <xs:complexType name="UI">
                <xs:all>
                        <xs:element name="author" type="xs:string" minOccurs="0" />
                        <xs:element name="comment" type="xs:string" minOccurs="0" />
                        <xs:element name="exportmacro" type="xs:string" minOccurs="0" />
                        <xs:element name="class" type="xs:string" />
                        <xs:element name="widget" type="Widget" />
                        <xs:element name="layoutdefault" type="LayoutDefault" minOccurs="0" />
                        <xs:element name="layoutfunction" type="LayoutFunction" minOccurs="0" />
                        <xs:element name="pixmapfunction" type="xs:string" minOccurs="0" />
                        <xs:element name="customwidgets" type="CustomWidgets" minOccurs="0" />
                        <xs:element name="tabstops" type="TabStops" minOccurs="0" />
                        <xs:element name="images" use="deprecated" />
                        <xs:element name="includes" type="Includes" minOccurs="0" />
                        <xs:element name="resources" type="Resources" minOccurs="0" />
                        <xs:element name="connections" type="Connections" minOccurs="0" />
                        <xs:element name="designerdata" type="DesignerData" minOccurs="0" />
                        <xs:element name="slots" type="Slots" minOccurs="0" />
                        <xs:element name="buttongroups" type="ButtonGroups" minOccurs="0" />
                </xs:all>
                <xs:attribute name="version" type="xs:string" />
                <xs:attribute name="language" type="xs:string" />
                <xs:attribute name="displayname" type="xs:string" />
                <xs:attribute name="idbasedtr" type="xs:boolean" />
<!-- Legacy attribute generated by uic3 -->
                <xs:attribute name="stdsetdef" type="xs:integer" />
<!-- Legacy attribute generated by the VS integration -->
                <xs:attribute name="stdSetDef" type="xs:integer" />
        </xs:complexType>
<!-- include begin -->
        <xs:complexType name="Includes">
            <xs:sequence>
                        <xs:element name="include" type="Include" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Include" mixed="true" >
                <xs:attribute name="location" type="xs:string" />
                <xs:attribute name="impldecl" type="xs:string" />
        </xs:complexType>
<!-- include end -->
<!-- resource begin -->
        <xs:complexType name="Resources">
            <xs:sequence>
                        <xs:element name="include" type="Resource" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
                <xs:attribute name="name" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="Resource">
                <xs:attribute name="location" type="xs:string" />
        </xs:complexType>
<!-- resource end -->
<!-- actions begin -->
        <xs:complexType name="ActionGroup">
                <xs:sequence maxOccurs="unbounded">
                        <xs:element name="action" type="Action" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="actiongroup" type="ActionGroup" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="name" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="Action">
                <xs:sequence maxOccurs="unbounded" >
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="name" type="xs:string" />
                <xs:attribute name="menu" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="ActionRef">
                <xs:attribute name="name" type="xs:string" />
        </xs:complexType>
<!-- actions end -->
<!-- button groups begin -->
        <xs:complexType name="ButtonGroup">
                <xs:sequence maxOccurs="unbounded">
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="name" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="ButtonGroups">
            <xs:sequence>
                        <xs:element name="buttongroup" type="ButtonGroup" maxOccurs="unbounded" />
        </xs:sequence>
        </xs:complexType>
<!--  button groups end -->
<!-- custom widget support begin -->
        <xs:complexType name="CustomWidgets">
            <xs:sequence>
                        <xs:element name="customwidget" type="CustomWidget" maxOccurs="unbounded" />
        </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Header" mixed="true" >
                <xs:attribute name="location" type="xs:string" />  <!-- local or global -->
        </xs:complexType>
        <xs:complexType name="CustomWidget">
                <xs:all>
                        <xs:element name="class" type="xs:string" />
                        <xs:element name="extends" type="xs:string" />
                        <xs:element name="header" type="Header" />
                        <xs:element name="sizehint" type="Size" minOccurs="0" />
                        <xs:element name="addpagemethod" type="xs:string" minOccurs="0" />
                        <xs:element name="container" type="xs:integer" minOccurs="0" />
                        <xs:element name="sizepolicy" use="deprecated" />
                        <xs:element name="pixmap" type="xs:string" minOccurs="0" />
                        <xs:element name="script" use="deprecated" />
                        <xs:element name="properties" use="deprecated" />
                        <xs:element name="slots" type="Slots" minOccurs="0" />
                        <xs:element name="propertyspecifications" type="PropertySpecifications" minOccurs="0" />
                </xs:all>
        </xs:complexType>
<!-- custom widget support end -->
        <xs:complexType name="LayoutDefault">
                <xs:attribute name="spacing" type="xs:integer" />
                <xs:attribute name="margin" type="xs:integer" />
        </xs:complexType>
        <xs:complexType name="LayoutFunction">
                <xs:attribute name="spacing" type="xs:string" />
                <xs:attribute name="margin" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="TabStops">
                <xs:sequence>
                        <xs:element name="tabstop" type="xs:string" maxOccurs="unbounded" />
        </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Layout">
                <xs:sequence maxOccurs="unbounded" >
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="item" type="LayoutItem" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="class" type="xs:string" />
                <xs:attribute name="name" type="xs:string" />
                <xs:attribute name="stretch" type="xs:string" />
                <xs:attribute name="rowstretch" type="xs:string" />
                <xs:attribute name="columnstretch" type="xs:string" />
                <xs:attribute name="rowminimumheight" type="xs:string" />
                <xs:attribute name="columnminimumwidth" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="LayoutItem">
                <xs:choice>
                        <xs:element name="widget" type="Widget" />
                        <xs:element name="layout" type="Layout" />
                        <xs:element name="spacer" type="Spacer" />
                </xs:choice>
                <xs:attribute name="row" type="xs:integer" />
                <xs:attribute name="column" type="xs:integer" />
                <xs:attribute name="rowspan" type="xs:integer" />
                <xs:attribute name="colspan" type="xs:integer" />
                <xs:attribute name="alignment" type="xs:string" />
        </xs:complexType>
<!-- item view begin -->
        <xs:complexType name="Row">
            <xs:sequence>
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Column">
            <xs:sequence>
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Item">
                <xs:sequence maxOccurs="unbounded">
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="item" type="Item" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="row" type="xs:integer" />
                <xs:attribute name="column" type="xs:integer" />
        </xs:complexType>
<!-- item view end -->
        <xs:complexType name="Widget">
            <!-- Order does not matter (cannot use xs:all here
                     because of unbounded row, column, item -->
                <xs:sequence>
                        <xs:element name="class" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> <!-- unbounded kept for compatibility reasons -->
                        <xs:element name="property" type="Property" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="script" use="deprecated" />
                        <xs:element name="widgetdata" use="deprecated" />
                        <xs:element name="attribute" type="Property" minOccurs="0" maxOccurs="unbounded" />
<!-- item view begin -->
                        <xs:element name="row" type="Row" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="column" type="Column"  minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="item" type="Item" minOccurs="0" maxOccurs="unbounded" />
<!-- item view end -->
                        <xs:element name="layout" type="Layout" minOccurs="0" maxOccurs="unbounded" /> <!-- unbounded kept for compatibility reasons -->
                        <xs:element name="widget" type="Widget" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="action" type="Action" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="actiongroup" type="ActionGroup" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="addaction" type="ActionRef" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="zorder" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
                <xs:attribute name="class" type="xs:string" />
                <xs:attribute name="name" type="xs:string" />
                <xs:attribute name="native" type="xs:boolean" />
        </xs:complexType>
        <xs:complexType name="Spacer">
            <xs:sequence>
                        <xs:element name="property" type="Property" maxOccurs="unbounded" />
        </xs:sequence>
                <xs:attribute name="name" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="Color">
                <xs:all>
                    <xs:element name="red" type="xs:integer" />
                    <xs:element name="green" type="xs:integer" />
                    <xs:element name="blue" type="xs:integer" />
                </xs:all>
                <xs:attribute name="alpha" type="xs:integer" />
        </xs:complexType>
        <xs:complexType name="GradientStop">
            <xs:sequence>
                        <xs:element name="color" type="Color" />
            </xs:sequence>
                <xs:attribute name="position" type="xs:double" />
        </xs:complexType>
        <xs:complexType name="Gradient">
            <xs:sequence>
                        <xs:element name="gradientStop" type="GradientStop" maxOccurs="unbounded" />
            </xs:sequence>
                <xs:attribute name="startx" type="xs:double" />
                <xs:attribute name="starty" type="xs:double" />
                <xs:attribute name="endx" type="xs:double" />
                <xs:attribute name="endy" type="xs:double" />
                <xs:attribute name="centralx" type="xs:double" />
                <xs:attribute name="centraly" type="xs:double" />
                <xs:attribute name="focalx" type="xs:double" />
                <xs:attribute name="focaly" type="xs:double" />
                <xs:attribute name="radius" type="xs:double" />
                <xs:attribute name="angle" type="xs:double" />
                <xs:attribute name="type" type="xs:string" />
                <xs:attribute name="spread" type="xs:string" />
                <xs:attribute name="coordinatemode" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="Brush">
                <xs:choice>
                    <xs:element name="color" type="Color" />
                    <xs:element name="texture" type="Property" />
                    <xs:element name="gradient" type="Gradient" />
                </xs:choice>
                <xs:attribute name="brushstyle" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="ColorRole">
            <xs:sequence>
                        <xs:element name="brush" type="Brush" />
            </xs:sequence>
                <xs:attribute name="role" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="ColorGroup">
                <xs:sequence maxOccurs="unbounded">
                        <xs:element name="colorrole" type="ColorRole" minOccurs="0" maxOccurs="unbounded" />
                        <xs:element name="color" type="Color" minOccurs="0" maxOccurs="unbounded" />
                </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Palette">
                <xs:all>
                        <xs:element name="active" type="ColorGroup" />
                        <xs:element name="inactive" type="ColorGroup" />
                        <xs:element name="disabled" type="ColorGroup" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Font">
                <xs:all>
                        <xs:element name="family" type="xs:string" minOccurs="0" />
                        <xs:element name="pointsize" type="xs:integer" minOccurs="0" />
                        <xs:element name="weight" type="xs:integer" minOccurs="0" />
                        <xs:element name="italic" type="xs:boolean" minOccurs="0" />
                        <xs:element name="bold" type="xs:boolean" minOccurs="0" />
                        <xs:element name="underline" type="xs:boolean" minOccurs="0" />
                        <xs:element name="strikeout" type="xs:boolean" minOccurs="0" />
                        <xs:element name="antialiasing" type="xs:boolean" minOccurs="0" />
                        <xs:element name="stylestrategy" type="xs:string" minOccurs="0" />
                        <xs:element name="kerning" type="xs:boolean" minOccurs="0" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Point">
                <xs:all>
                        <xs:element name="x" type="xs:integer" />
                        <xs:element name="y" type="xs:integer" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Rect">
                <xs:all>
                        <xs:element name="x" type="xs:integer" />
                        <xs:element name="y" type="xs:integer" />
                        <xs:element name="width" type="xs:integer" />
                        <xs:element name="height" type="xs:integer" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Locale">
                <xs:attribute name="language" type="xs:string" />
                <xs:attribute name="country" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="SizePolicy">
                <xs:all>
                        <xs:element name="hsizetype" type="xs:integer" minOccurs="0" />
                        <xs:element name="vsizetype" type="xs:integer" minOccurs="0" />
                        <xs:element name="horstretch" type="xs:integer" />
                        <xs:element name="verstretch" type="xs:integer" />
                </xs:all>
                <xs:attribute name="hsizetype" type="xs:string" />
                <xs:attribute name="vsizetype" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="Size">
                <xs:all>
                        <xs:element name="width" type="xs:integer" />
                        <xs:element name="height" type="xs:integer" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Date">
                <xs:all>
                        <xs:element name="year" type="xs:integer" />
                        <xs:element name="month" type="xs:integer" />
                        <xs:element name="day" type="xs:integer" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Time">
                <xs:all>
                        <xs:element name="hour" type="xs:integer" />
                        <xs:element name="minute" type="xs:integer" />
                        <xs:element name="second" type="xs:integer" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="DateTime">
                <xs:all>
                        <xs:element name="hour" type="xs:integer" />
                        <xs:element name="minute" type="xs:integer" />
                        <xs:element name="second" type="xs:integer" />
                        <xs:element name="year" type="xs:integer" />
                        <xs:element name="month" type="xs:integer" />
                        <xs:element name="day" type="xs:integer" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="StringList">
                <xs:attribute name="notr" type="xs:string" />
                <xs:attribute name="comment" type="xs:string" />
                <xs:attribute name="extracomment" type="xs:string" />
                <xs:attribute name="id" type="xs:string" />
            <xs:sequence>
                        <xs:element name="string" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="ResourcePixmap" mixed="true">
                <xs:attribute name="resource" type="xs:string" />
                <xs:attribute name="alias" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="ResourceIcon" mixed="true">
                <xs:all>
                        <xs:element name="normaloff" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="normalon" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="disabledoff" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="disabledon" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="activeoff" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="activeon" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="selectedoff" type="ResourcePixmap" minOccurs="0" />
                        <xs:element name="selectedon" type="ResourcePixmap" minOccurs="0" />
                </xs:all>
                <xs:attribute name="theme" type="xs:string" />
                <xs:attribute name="resource" type="xs:string" /> <!-- pre 4.4 legacy support -->
        </xs:complexType>
        <xs:complexType name="String" mixed="true">
                <xs:attribute name="notr" type="xs:string" />
                <xs:attribute name="comment" type="xs:string" />
                <xs:attribute name="extracomment" type="xs:string" />
                <xs:attribute name="id" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="PointF">
                <xs:all>
                        <xs:element name="x" type="xs:double" />
                        <xs:element name="y" type="xs:double" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="RectF">
                <xs:all>
                        <xs:element name="x" type="xs:double" />
                        <xs:element name="y" type="xs:double" />
                        <xs:element name="width" type="xs:double" />
                        <xs:element name="height" type="xs:double" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="SizeF">
                <xs:all>
                        <xs:element name="width" type="xs:double" />
                        <xs:element name="height" type="xs:double" />
                </xs:all>
        </xs:complexType>
        <xs:complexType name="Char">
            <xs:sequence>
                        <xs:element name="unicode" type="xs:integer" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Url">
            <xs:sequence>
                        <xs:element name="string" type="String" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Property">
                <xs:choice>
                        <xs:element name="bool" type="xs:string" />
                        <xs:element name="color" type="Color" />
                        <xs:element name="cstring" type="xs:string" />
                        <xs:element name="cursor" type="xs:integer" />
                        <xs:element name="cursorshape" type="xs:string" />
                        <xs:element name="enum" type="xs:string" />
                        <xs:element name="font" type ="Font" />
                        <xs:element name="iconset" type="ResourceIcon"/>
                        <xs:element name="pixmap" type="ResourcePixmap" />
                        <xs:element name="palette" type="Palette" />
                        <xs:element name="point" type="Point" />
                        <xs:element name="rect" type="Rect" />
                        <xs:element name="set" type="xs:string" />
                        <xs:element name="locale" type="Locale" />
                        <xs:element name="sizepolicy" type="SizePolicy" />
                        <xs:element name="size" type="Size" />
                        <xs:element name="string" type="String" />
                        <xs:element name="stringlist" type="StringList" />
                        <xs:element name="number" type="xs:integer" />
                        <xs:element name="float" type="xs:float" />
                        <xs:element name="double" type="xs:double" />
                        <xs:element name="date" type="Date" />
                        <xs:element name="time" type="Time" />
                        <xs:element name="datetime" type="DateTime" />
                        <xs:element name="pointf" type="PointF" />
                        <xs:element name="rectf" type="RectF" />
                        <xs:element name="sizef" type="SizeF" />
                        <xs:element name="longlong" type="xs:long" />
                        <xs:element name="char" type="Char" />
                        <xs:element name="url" type="Url" />
                        <xs:element name="uint" type="xs:unsignedInt" />
                        <xs:element name="ulonglong" type="xs:unsignedLong" />
                        <xs:element name="brush" type="Brush" />
                </xs:choice>
                <xs:attribute name="name" type="xs:string" />
                <xs:attribute name="stdset" type="xs:integer" />
        </xs:complexType>
        <xs:complexType name="Connections">
            <xs:sequence>
                        <xs:element name="connection" type="Connection" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Connection">
            <xs:all>
                <xs:element name="sender" type="xs:string" />
                <xs:element name="signal" type="xs:string" />
                <xs:element name="receiver" type="xs:string" />
                <xs:element name="slot" type="xs:string" />
                <xs:element name="hints" type="ConnectionHints" minOccurs="0" />
            </xs:all>
        </xs:complexType>
        <xs:complexType name="ConnectionHints">
            <xs:sequence>
                        <xs:element name="hint" type="ConnectionHint" maxOccurs="unbounded" />
               </xs:sequence>
        </xs:complexType>
        <xs:complexType name="ConnectionHint">
            <xs:all>
                <xs:element name="x" type="xs:integer"/>
                <xs:element name="y" type="xs:integer"/>
            </xs:all>
            <xs:attribute name="type" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="DesignerData">
            <xs:sequence>
                <xs:element name="property" type="Property" maxOccurs="unbounded" />
        </xs:sequence>
        </xs:complexType>
        <xs:complexType name="Slots">
            <xs:sequence maxOccurs="unbounded">
                <xs:element name="signal" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
                <xs:element name="slot" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="PropertySpecifications">
            <xs:sequence maxOccurs="unbounded">
               <xs:element name="tooltip" type="PropertyToolTip" minOccurs="0" maxOccurs="unbounded" />
               <xs:element name="stringpropertyspecification" type="StringPropertySpecification" minOccurs="0" maxOccurs="unbounded" />
            </xs:sequence>
        </xs:complexType>
        <xs:complexType name="PropertyToolTip">
            <xs:attribute name="name" type="xs:string" />
        </xs:complexType>
        <xs:complexType name="StringPropertySpecification">
            <xs:attribute name="name" type="xs:string" />
            <xs:attribute name="type" type="xs:string" />
            <xs:attribute name="notr" type="xs:string" />
        </xs:complexType>
</xs:schema>