1QWidgetFactory(3qt) QWidgetFactory(3qt)
2
3
4
6 QWidgetFactory - For the dynamic creation of widgets from Qt Designer
7 .ui files
8
10 #include <qwidgetfactory.h>
11
12 Public Members
13 QWidgetFactory ()
14 virtual ~QWidgetFactory ()
15 virtual QWidget * createWidget ( const QString & className, QWidget *
16 parent, const char * name ) const
17
18 Static Public Members
19 QWidget * create ( const QString & uiFile, QObject * connector = 0,
20 QWidget * parent = 0, const char * name = 0 )
21 QWidget * create ( QIODevice * dev, QObject * connector = 0, QWidget *
22 parent = 0, const char * name = 0 )
23 void addWidgetFactory ( QWidgetFactory * factory )
24 void loadImages ( const QString & dir )
25 QStringList widgets ()
26 bool supportsWidget ( const QString & widget )
27
29 The QWidgetFactory class provides for the dynamic creation of widgets
30 from Qt Designer .ui files.
31
32 This class basically offers two things:
33
34 Dynamically creating widgets from Qt Designer user interface
35 description files. You can do this using the static function
36 QWidgetFactory::create(). This function also performs signal and slot
37 connections, tab ordering, etc., as defined in the .ui file, and
38 returns the top-level widget in the .ui file. After creating the widget
39 you can use QObject::child() and QObject::queryList() to access child
40 widgets of this returned widget.
41
42 Adding additional widget factories to be able to create custom widgets.
43 See createWidget() for details.
44
45 This class is not included in the Qt library itself. To use it you must
46 link against libqui.so (Unix) or qui.lib (Windows), which is built into
47 INSTALL/lib if you built Qt Designer (INSTALL is the directory where Qt
48 is installed ).
49
50 If you create a QMainWindow using a QWidgetFactory, be aware that it
51 already has a central widget. Therefore, you need to delete this one
52 before setting another one.
53
54 See the "Creating Dynamic Dialogs from .ui Files" section of the Qt
55 Designer manual for an example. See also the QWidgetPlugin class and
56 the Plugins documentation.
57
60 Constructs a QWidgetFactory.
61
63 Destructor.
64
66 Installs a widget factory factory, which normally contains additional
67 widgets that can then be created using a QWidgetFactory. See
68 createWidget() for further details.
69
71 = 0, QWidget * parent = 0, const char * name = 0 ) [static]
72 Loads the Qt Designer user interface description file uiFile and
73 returns the top-level widget in that description. parent and name are
74 passed to the constructor of the top-level widget.
75
76 This function also performs signal and slot connections, tab ordering,
77 etc., as described in the .ui file. In Qt Designer it is possible to
78 add custom slots to a form and connect to them. If you want these
79 connections to be made, you must create a class derived from QObject,
80 which implements all these slots. Then pass an instance of the object
81 as connector to this function. If you do this, the connections to the
82 custom slots will be done using the connector as slot.
83
84 If something fails, 0 is returned.
85
86 The ownership of the returned widget is passed to the caller.
87
89 QWidget * parent = 0, const char * name = 0 ) [static]
90 This is an overloaded member function, provided for convenience. It
91 behaves essentially like the above function.
92
93 Loads the user interface description from device dev.
94
96 parent, const char * name ) const [virtual]
97 Creates a widget of the type className passing parent and name to its
98 constructor.
99
100 If className is a widget in the Qt library, it is directly created by
101 this function. If the widget isn't in the Qt library, each of the
102 installed widget plugins is asked, in turn, to create the widget. As
103 soon as a plugin says it can create the widget it is asked to do so. It
104 may occur that none of the plugins can create the widget, in which case
105 each installed widget factory is asked to create the widget (see
106 addWidgetFactory()). If the widget cannot be created by any of these
107 means, 0 is returned.
108
109 If you have a custom widget, and want it to be created using the widget
110 factory, there are two approaches you can use:
111
112 <ol type=1>
113
114 Write a widget plugin. This allows you to use the widget in Qt Designer
115 and in this QWidgetFactory. See the widget plugin documentation for
116 further details. (See the "Creating Custom Widgets with Plugins"
117 section of the Qt Designer manual for an example.
118
119 Subclass QWidgetFactory. Then reimplement this function to create and
120 return an instance of your custom widget if className equals the name
121 of your widget, otherwise return 0. Then at the beginning of your
122 program where you want to use the widget factory to create widgets do
123 a:
124
125 QWidgetFactory::addWidgetFactory( new MyWidgetFactory );
126 where MyWidgetFactory is your QWidgetFactory subclass.
127
129 If you use a pixmap collection (which is the default for new projects)
130 rather than saving the pixmaps within the .ui XML file, you must load
131 the pixmap collection. QWidgetFactory looks in the default
132 QMimeSourceFactory for the pixmaps. Either add it there manually, or
133 call this function and specify the directory where the images can be
134 found, as dir. This is normally the directory called images in the
135 project's directory.
136
138 Returns TRUE if the widget factory can create the specified widget;
139 otherwise returns FALSE.
140
142 Returns the names of the widgets this factory can create.
143
144
146 http://doc.trolltech.com/qwidgetfactory.html
147 http://www.trolltech.com/faq/tech.html
148
150 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
151 license file included in the distribution for a complete license
152 statement.
153
155 Generated automatically from the source code.
156
158 If you find a bug in Qt, please report it as described in
159 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
160 help you. Thank you.
161
162 The definitive Qt documentation is provided in HTML format; it is
163 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
164 web browser. This man page is provided as a convenience for those users
165 who prefer man pages, although this format is not officially supported
166 by Trolltech.
167
168 If you find errors in this manual page, please report them to qt-
169 bugs@trolltech.com. Please include the name of the manual page
170 (qwidgetfactory.3qt) and the Qt version (3.3.8).
171
172
173
174Trolltech AS 2 February 2007 QWidgetFactory(3qt)