<?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="index.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 class="cpp"> <span class="preprocessor">#include customwidgetoneinterface.h</span> <span class="preprocessor">#include customwidgettwointerface.h</span> <span class="preprocessor">#include customwidgetthreeinterface.h</span> <span class="preprocessor">#include <QtDesigner/QtDesigner></span> <span class="preprocessor">#include <QtCore/qplugin.h></span> <span class="keyword">class</span> MyCustomWidgets: <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span><span class="operator">,</span> <span class="keyword">public</span> <span class="type">QDesignerCustomWidgetCollectionInterface</span> { Q_OBJECT Q_INTERFACES(<span class="type">QDesignerCustomWidgetCollectionInterface</span>) <span class="keyword">public</span>: MyCustomWidgets(<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>); <span class="keyword">virtual</span> <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a></span><span class="operator">*</span><span class="operator">></span> customWidgets() <span class="keyword">const</span>; <span class="keyword">private</span>: <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a></span><span class="operator">*</span><span class="operator">></span> 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 class="cpp"> MyCustomWidgets<span class="operator">.</span>MyCustomWidgets(<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>parent) : <span class="type"><a href="qobject.html">QObject</a></span>(parent) { widgets<span class="operator">.</span>append(<span class="keyword">new</span> CustomWidgetOneInterface(<span class="keyword">this</span>)); widgets<span class="operator">.</span>append(<span class="keyword">new</span> CustomWidgetTwoInterface(<span class="keyword">this</span>)); widgets<span class="operator">.</span>append(<span class="keyword">new</span> CustomWidgetThreeInterface(<span class="keyword">this</span>)); } <span class="type"><a href="qlist.html">QList</a></span><span class="operator"><</span><span class="type"><a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a></span><span class="operator">*</span><span class="operator">></span> MyCustomWidgets<span class="operator">.</span><a href="qdesignercustomwidgetcollectioninterface.html#customWidgets">customWidgets</a>() <span class="keyword">const</span> { <span class="keyword">return</span> widgets; } <a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a>(customwidgetsplugin<span class="operator">,</span> 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> <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> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.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> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>