QWidgetFactory Class Reference
The QWidgetFactory class provides for the creation of dynamically
create widgets from Qt Designer user interface description files.
More...
#include <qwidgetfactory.h>
List of all member functions.
Public Members
virtual QWidget *
createWidget ( const QString & className, QWidget * parent, const char * name ) const
Static Public Members
QWidget *
create ( const QString & uiFile, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 )
QWidget *
create ( QIODevice * dev, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 )
Detailed Description
The QWidgetFactory class provides for the creation of dynamically
create widgets from Qt Designer user interface description files.
This class basically offers two things:
- Dynamically creating widgets from Qt Designer user interface
description files. You can do that using the static function
QWidgetFactory::create(). This function also performs signal and
slot connections, tab ordering, etc. as defined in the ui file and
returns the toplevel widget of the ui file. After that you can use
QObject::child() and QObject::queryList() to access child widgets of
this returned widget.
- Adding additional widget factories to be able to create custom
widgets. See createWidget() for details.
This class is not included in the Qt library itself. To use it you
have to link against libqui.so (Unix) or qui.lib (Windows), which is
build into $(QTDIR)/lib if you built the Qt Designer. Also to be
able to include qwidgetfactory.h you have to add
$(QTDIR)/tools/designer/uilib to your project's include path.
Member Function Documentation
QWidgetFactory::QWidgetFactory ()
Constructs a QWidgetFactory.
QWidgetFactory::~QWidgetFactory () [virtual]
Destructor.
void QWidgetFactory::addWidgetFactory ( QWidgetFactory * factory ) [static]
Installs a widget factory factory, which normally contains
additional widgets that can be created using a QWidgetFactory
then. See createWidget() for further details.
QWidget * QWidgetFactory::create ( const QString & uiFile, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 ) [static]
Loads the Qt Designer user interface description file uiFile
and returns the toplevel widget of that description. parent and
name are passed to the constructor of the toplevel widget.
This function also performs signal and slot connections, tab
ordering, etc. as described in the ui file. In the Qt Designer it is
possible to add custom slots to a form and connect to them. If you
want that these connections are performed as well, you have to
create a class derived from QObject, which implementes all these
slots. Then pass an instance of it as connector to this
function. This way these connections to custom slots will be done
using the connector as slot.
If something fails, 0 is returned.
The ownership of the returned widget is passed to the caller.
QWidget * QWidgetFactory::create ( QIODevice * dev, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 ) [static]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Loads the user interface description from the dev device.
QWidget * QWidgetFactory::createWidget ( const QString & className, QWidget * parent, const char * name ) const [virtual]
Creates the widget of the type className passing parent and
name to its constructor. If className is a widget of the Qt
library, it is directly created in this function. if this fails, all
installed widget plugins are asked to create that widget. If this
fails all installed widget factories are asked to create it (see
addWidgetFactory()). If this fails as well, 0 is returned.
If you have a custom widget, and want it to be created using the
widget factory, you have two possibilities to add it:
void QWidgetFactory::loadImages ( const QString & dir ) [static]
If the pixmaps of the form are not saved in the XML file, but you
used a project with a pixmap collection, you have to load this
pixmap collection. QWidgetFactory looks in the default
QMimeSourceFactory for the pixmaps. Either you add it there
manually, or call this function and specify the directory where
the images can be found, as dir. This is normally the directory
images in the project directory.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit,
copyright © 1995-2001
Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks
| Qt version 3.0.0-beta3
|