1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDesignerCustomWidgetCollectionInterface Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDesignerCustomWidgetCollectionInterface Class Reference<br /><sup><sup>[<a href="qtdesigner.html">QtDesigner</a> module]</sup></sup></h1><p>The QDesignerCustomWidgetCollectionInterface class allows you to include several custom widgets in one single library. <a href="#details">More...</a></p>
<p>Inherited by <a href="qpydesignercustomwidgetcollectionplugin.html">QPyDesignerCustomWidgetCollectionPlugin</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdesignercustomwidgetcollectioninterface.html#QDesignerCustomWidgetCollectionInterface">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdesignercustomwidgetcollectioninterface.html#QDesignerCustomWidgetCollectionInterface-2">__init__</a></b> (<i>self</i>, QDesignerCustomWidgetCollectionInterface)</li><li><div class="fn" />list-of-QDesignerCustomWidgetInterface <b><a href="qdesignercustomwidgetcollectioninterface.html#customWidgets">customWidgets</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDesignerCustomWidgetCollectionInterface class allows you to include several custom widgets in one single library.</p>
<p>When implementing a custom widget plugin, you build it as a separate library. If you want to include several custom widget plugins in the same library, you must in addition subclass QDesignerCustomWidgetCollectionInterface.</p>
<p>QDesignerCustomWidgetCollectionInterface contains one single function returning a list of the collection's <a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a> objects. For example, if you have several custom widgets <tt>CustomWidgetOne</tt>, <tt>CustomWidgetTwo</tt> and <tt>CustomWidgetThree</tt>, the class definition may look like this:</p>
<pre> #include customwidgetoneinterface.h
#include customwidgettwointerface.h
#include customwidgetthreeinterface.h
#include <QtDesigner/QtDesigner>
#include <QtCore/qplugin.h>
class MyCustomWidgets: public QObject, public QDesignerCustomWidgetCollectionInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetCollectionInterface)
public:
MyCustomWidgets(QObject *parent = 0);
virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const;
private:
QList<QDesignerCustomWidgetInterface*> widgets;
};</pre>
<p>In the class constructor you add the interfaces to your custom widgets to the list which you return in the <a href="qdesignercustomwidgetcollectioninterface.html#customWidgets">customWidgets</a>() function:</p>
<pre> MyCustomWidgets.MyCustomWidgets(QObject *parent)
: QObject(parent)
{
widgets.append(new CustomWidgetOneInterface(this));
widgets.append(new CustomWidgetTwoInterface(this));
widgets.append(new CustomWidgetThreeInterface(this));
}
QList<QDesignerCustomWidgetInterface*> MyCustomWidgets.customWidgets() const
{
return widgets;
}
Q_EXPORT_PLUGIN2(customwidgetsplugin, MyCustomWidgets)</pre>
<p>Note that instead of exporting each custom widget plugin using the <a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a>() macro, you export the entire collection. The <a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a>() macro ensures that <i>Qt Designer</i> can access and construct the custom widgets. Without this macro, there is no way for <i>Qt Designer</i> to use them.</p>
<p>See also <a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a> and <a href="designer-creating-custom-widgets.html">Creating Custom Widgets for Qt Designer</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDesignerCustomWidgetCollectionInterface" />QDesignerCustomWidgetCollectionInterface.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QDesignerCustomWidgetCollectionInterface-2" />QDesignerCustomWidgetCollectionInterface.__init__ (<i>self</i>, <a href="qdesignercustomwidgetcollectioninterface.html">QDesignerCustomWidgetCollectionInterface</a>)</h3><h3 class="fn"><a name="customWidgets" />list-of-QDesignerCustomWidgetInterface QDesignerCustomWidgetCollectionInterface.customWidgets (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns a list of interfaces to the collection's custom widgets.</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.2</td></tr></table></div></address></body></html>
|