source: trunk/doc/html/qwidgetfactory.html@ 203

Last change on this file since 203 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 10.3 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/tools/designer/uilib/qwidgetfactory.cpp:207 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QWidgetFactory Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QWidgetFactory Class Reference</h1>
33
34<p>The QWidgetFactory class provides for the dynamic creation of widgets
35from Qt Designer .ui files.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qwidgetfactory-h.html">qwidgetfactory.h</a>&gt;</tt>
38<p><a href="qwidgetfactory-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QWidgetFactory"><b>QWidgetFactory</b></a> ()</li>
42<li class=fn>virtual <a href="#~QWidgetFactory"><b>~QWidgetFactory</b></a> ()</li>
43<li class=fn>virtual QWidget * <a href="#createWidget"><b>createWidget</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;className, QWidget&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name ) const</li>
44</ul>
45<h2>Static Public Members</h2>
46<ul>
47<li class=fn>QWidget * <a href="#create"><b>create</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;uiFile, QObject&nbsp;*&nbsp;connector = 0, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
48<li class=fn>QWidget * <a href="#create-2"><b>create</b></a> ( QIODevice&nbsp;*&nbsp;dev, QObject&nbsp;*&nbsp;connector = 0, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
49<li class=fn>void <a href="#addWidgetFactory"><b>addWidgetFactory</b></a> ( QWidgetFactory&nbsp;*&nbsp;factory )</li>
50<li class=fn>void <a href="#loadImages"><b>loadImages</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;dir )</li>
51<li class=fn>QStringList <a href="#widgets"><b>widgets</b></a> ()</li>
52<li class=fn>bool <a href="#supportsWidget"><b>supportsWidget</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;widget )</li>
53</ul>
54<hr><a name="details"></a><h2>Detailed Description</h2>
55
56
57<p> The QWidgetFactory class provides for the dynamic creation of widgets
58from Qt Designer .ui files.
59<p> This class basically offers two things:
60<p> <ul>
61<p> <li> Dynamically creating widgets from <a href="designer-manual.html">Qt
62 Designer</a> user interface description files.
63You can do this using the static function <a href="#create">QWidgetFactory::create</a>().
64This function also performs signal and slot connections, tab
65ordering, etc., as defined in the .ui file, and returns the
66top-level widget in the .ui file. After creating the widget you can
67use <a href="qobject.html#child">QObject::child</a>() and <a href="qobject.html#queryList">QObject::queryList</a>() to access child
68widgets of this returned widget.
69<p> <li> Adding additional widget factories to be able to create custom
70widgets. See <a href="#createWidget">createWidget</a>() for details.
71<p> </ul>
72<p> This class is not included in the Qt library itself. To use it you
73must link against <tt>libqui.so</tt> (Unix) or <tt>qui.lib</tt> (Windows), which is
74built into <tt>INSTALL/lib</tt> if you built <em>Qt Designer</em> (<tt>INSTALL</tt> is
75the directory where Qt is installed ).
76<p> If you create a <a href="qmainwindow.html">QMainWindow</a> using a QWidgetFactory, be aware that
77it already has a central widget. Therefore, you need to delete this
78one before setting another one.
79<p> See the "Creating Dynamic Dialogs from .ui Files" section of the <a href="designer-manual.html">Qt Designer manual</a> for an example. See
80also the <a href="qwidgetplugin.html">QWidgetPlugin</a> class and the <a href="plugins-howto.html">Plugins documentation</a>.
81
82<hr><h2>Member Function Documentation</h2>
83<h3 class=fn><a name="QWidgetFactory"></a>QWidgetFactory::QWidgetFactory ()
84</h3> Constructs a QWidgetFactory.
85<h3 class=fn><a name="~QWidgetFactory"></a>QWidgetFactory::~QWidgetFactory ()<tt> [virtual]</tt>
86</h3>
87Destructor.
88
89<h3 class=fn>void <a name="addWidgetFactory"></a>QWidgetFactory::addWidgetFactory ( <a href="qwidgetfactory.html">QWidgetFactory</a>&nbsp;*&nbsp;factory )<tt> [static]</tt>
90</h3> Installs a widget factory <em>factory</em>, which normally contains
91additional widgets that can then be created using a QWidgetFactory.
92See <a href="#createWidget">createWidget</a>() for further details.
93
94<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="create"></a>QWidgetFactory::create ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;uiFile, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;connector = 0, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )<tt> [static]</tt>
95</h3>
96<p> Loads the <em>Qt Designer</em> user interface description file <em>uiFile</em>
97and returns the top-level widget in that description. <em>parent</em> and
98<em>name</em> are passed to the constructor of the top-level widget.
99<p> This function also performs signal and slot connections, tab
100ordering, etc., as described in the .ui file. In <em>Qt Designer</em> it
101is possible to add custom slots to a form and connect to them. If
102you want these connections to be made, you must create a class
103derived from <a href="qobject.html">QObject</a>, which implements all these slots. Then pass an
104instance of the object as <em>connector</em> to this function. If you do
105this, the connections to the custom slots will be done using the <em>connector</em> as slot.
106<p> If something fails, 0 is returned.
107<p> The ownership of the returned widget is passed to the caller.
108
109<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="create-2"></a>QWidgetFactory::create ( <a href="qiodevice.html">QIODevice</a>&nbsp;*&nbsp;dev, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;connector = 0, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )<tt> [static]</tt>
110</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
111<p> Loads the user interface description from device <em>dev</em>.
112
113<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="createWidget"></a>QWidgetFactory::createWidget ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;className, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name ) const<tt> [virtual]</tt>
114</h3>
115Creates a widget of the type <em>className</em> passing <em>parent</em> and <em>name</em> to its constructor.
116<p> If <em>className</em> is a widget in the Qt library, it is directly
117created by this function. If the widget isn't in the Qt library,
118each of the installed widget plugins is asked, in turn, to create
119the widget. As soon as a plugin says it can create the widget it
120is asked to do so. It may occur that none of the plugins can
121create the widget, in which case each installed widget factory is
122asked to create the widget (see <a href="#addWidgetFactory">addWidgetFactory</a>()). If the widget
123cannot be created by any of these means, 0 is returned.
124<p> If you have a custom widget, and want it to be created using the
125widget factory, there are two approaches you can use:
126<p> <ol type=1>
127<p> <li> Write a widget plugin. This allows you to use the widget in
128<em>Qt Designer</em> and in this QWidgetFactory. See the widget plugin
129documentation for further details. (See the "Creating Custom
130Widgets with Plugins" section of the <a href="designer-manual.html">Qt
131 Designer manual</a> for an example.
132<p> <li> Subclass QWidgetFactory. Then reimplement this function to
133create and return an instance of your custom widget if <em>className</em> equals the name of your widget, otherwise return 0. Then
134at the beginning of your program where you want to use the widget
135factory to create widgets do a:
136<pre>
137 QWidgetFactory::<a href="#addWidgetFactory">addWidgetFactory</a>( new MyWidgetFactory );
138 </pre>
139
140where MyWidgetFactory is your QWidgetFactory subclass.
141<p> </ol>
142
143<h3 class=fn>void <a name="loadImages"></a>QWidgetFactory::loadImages ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;dir )<tt> [static]</tt>
144</h3>
145If you use a pixmap collection (which is the default for new
146projects) rather than saving the pixmaps within the .ui XML file,
147you must load the pixmap collection. QWidgetFactory looks in the
148default <a href="qmimesourcefactory.html">QMimeSourceFactory</a> for the pixmaps. Either add it there
149manually, or call this function and specify the directory where
150the images can be found, as <em>dir</em>. This is normally the
151directory called <tt>images</tt> in the project's directory.
152
153<h3 class=fn>bool <a name="supportsWidget"></a>QWidgetFactory::supportsWidget ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;widget )<tt> [static]</tt>
154</h3> Returns TRUE if the widget factory can create the specified <em>widget</em>;
155otherwise returns FALSE.
156<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="widgets"></a>QWidgetFactory::widgets ()<tt> [static]</tt>
157</h3> Returns the names of the widgets this factory can create.
158<!-- eof -->
159<hr><p>
160This file is part of the <a href="index.html">Qt toolkit</a>.
161Copyright &copy; 1995-2007
162<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
163<table width=100% cellspacing=0 border=0><tr>
164<td>Copyright &copy; 2007
165<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
166<td align=right><div align=right>Qt 3.3.8</div>
167</table></div></address></body>
168</html>
Note: See TracBrowser for help on using the repository browser.