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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
<?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" />unknown-type <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" />unknown-type 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.12.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qt.io">The Qt Company</a> 2015</td><td align="right" width="25%">Qt 4.8.7</td></tr></table></div></address></body></html>
|