📄 qwidgetfactory.3qt
字号:
'\" t.TH QWidgetFactory 3qt "11 October 2001" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQWidgetFactory \- For the dynamic creation of widgets from Qt Designer .ui files.PP\fC#include <qwidgetfactory.h>\fR.PP.SS "Public Members".in +1c.ti -1c.BI "\fBQWidgetFactory\fR ()".br.ti -1c.BI "virtual \fB~QWidgetFactory\fR ()".br.ti -1c.BI "virtual QWidget * \fBcreateWidget\fR ( const QString & className, QWidget * parent, const char * name ) const".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "QWidget * \fBcreate\fR ( const QString & uiFile, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 )".br.ti -1c.BI "QWidget * \fBcreate\fR ( QIODevice * dev, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 )".br.ti -1c.BI "void \fBaddWidgetFactory\fR ( QWidgetFactory * factory )".br.ti -1c.BI "void \fBloadImages\fR ( const QString & dir )".br.in -1c.SH DESCRIPTIONThe QWidgetFactory class provides for the dynamic creation of widgets from Qt Designer .ui files..PPThis class basically offers two things:.IP.TPDynamically creating widgets from \fIQt Designer\fR user interface description files. You can do this 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 top-level widget in the .ui file. After creating the widget you can use QObject::child() and QObject::queryList() to access child widgets of this returned widget..IP.TPAdding additional widget factories to be able to create custom widgets. See createWidget() for details..IP.PPThis class is not included in the Qt library itself. To use it you must link against \fClibqui.so\fR (Unix) or \fCqui.lib\fR (Windows), which is built into \fC$(QTDIR)/lib\fR if you built \fIQt Designer\fR..PPSee the Creating Dynamic Dialogs from .ui Files section of the Qt Designer manual for an example..SH MEMBER FUNCTION DOCUMENTATION.SH "QWidgetFactory::QWidgetFactory ()"Constructs a QWidgetFactory..SH "QWidgetFactory::~QWidgetFactory ()\fC [virtual]\fR"Destructor..SH "void QWidgetFactory::addWidgetFactory ( QWidgetFactory * factory )\fC [static]\fR"Installs a widget factory \fIfactory\fR, which normally contains additional widgets that can then be created using a QWidgetFactory. See createWidget() for further details..SH "QWidget * QWidgetFactory::create ( const QString & uiFile, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 )\fC [static]\fR"Loads the \fIQt Designer\fR user interface description file \fIuiFile\fR and returns the top-level widget in that description. \fIparent\fR and \fIname\fR are passed to the constructor of the top-level widget..PPThis function also performs signal and slot connections, tab ordering, etc., as described in the .ui file. In \fIQt Designer\fR it is possible to add custom slots to a form and connect to them. If you want these connections to be made, you must create a class derived from QObject, which implements all these slots. Then pass an instance of the object as \fIconnector\fR to this function. If you do this, the connections to the custom slots will be done using the \fIconnector\fR as slot..PPIf something fails, 0 is returned..PPThe ownership of the returned widget is passed to the caller..SH "QWidget * QWidgetFactory::create ( QIODevice * dev, QObject * connector = 0, QWidget * parent = 0, const char * name = 0 )\fC [static]\fR"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPLoads the user interface description from device \fIdev\fR..SH "QWidget * QWidgetFactory::createWidget ( const QString & className, QWidget * parent, const char * name ) const\fC [virtual]\fR"Creates a widget of the type \fCclassName\fR passing \fIparent\fR and \fIname\fR to its constructor..PPIf \fIclassName\fR is a widget in the Qt library, it is directly created by this function. If the widget isn't in the Qt library, each of the installed widget plugins is asked, in turn, to create the widget. As soon as a plugin says it can create the widget it is asked to do so. It may occur that none of the plugins can create the widget, in which case each installed widget factory is asked to create the widget (see addWidgetFactory()). If the widget cannot be created by any of these means, 0 is returned..PPIf you have a custom widget, and want it to be created using the widget factory, there are two approaches you can use:.PP<ol type=1>.IP.TPWrite a widget plugin. This allows you to use the widget in \fIQt Designer\fR and in this QWidgetFactory. See the widget plugin documentation for further details. (See the Creating Custom Widgets with Plugins section of the Qt Designer manual for an example..IP.TPSubclass QWidgetFactory. Then reimplement this function to create and return an instance of your custom widget if \fIclassName\fR equals the name of your widget, otherwise return 0. Then at the beginning of your program where you want to use the widget factory to create widgets do a:.IP.nf.br QWidgetFactory::addWidgetFactory( new MyWidgetFactory );.br.fiwhere MyWidgetFactory is your QWidgetFactory subclass..IP.SH "void QWidgetFactory::loadImages ( const QString & dir )\fC [static]\fR"If you use a pixmap collection (which is the default for newprojects) rather than saving the pixmapswithin the .ui XML file, you must load thepixmap collection. QWidgetFactory looks in the defaultQMimeSourceFactory for the pixmaps. Either add it theremanually, or call this function and specify the directory wherethe images can be found, as \fIdir\fR. This is normally the directorycalled \fCimages\fR in the project's directory..SH "SEE ALSO".BR http://doc.trolltech.com/qwidgetfactory.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qwidgetfactory.3qt) and the Qtversion (3.0.0).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -