Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 608

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?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>QDesignerCustomWidgetInterface 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">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDesignerCustomWidgetInterface Class Reference<br /><sup><sup>[<a href="qtdesigner.html">QtDesigner</a> module]</sup></sup></h1><p>The QDesignerCustomWidgetInterface class enables Qt Designer to
access and construct custom widgets. <a href="#details">More...</a></p>

<p>Inherited by <a href="qpydesignercustomwidgetplugin.html">QPyDesignerCustomWidgetPlugin</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdesignercustomwidgetinterface.html#QDesignerCustomWidgetInterface">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdesignercustomwidgetinterface.html#QDesignerCustomWidgetInterface-2">__init__</a></b> (<i>self</i>, QDesignerCustomWidgetInterface)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#codeTemplate">codeTemplate</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qdesignercustomwidgetinterface.html#createWidget">createWidget</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#domXml">domXml</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#group">group</a></b> (<i>self</i>)</li><li><div class="fn" />QIcon <b><a href="qdesignercustomwidgetinterface.html#icon">icon</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#includeFile">includeFile</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdesignercustomwidgetinterface.html#initialize">initialize</a></b> (<i>self</i>, QDesignerFormEditorInterface&#160;<i>core</i>)</li><li><div class="fn" />bool <b><a href="qdesignercustomwidgetinterface.html#isContainer">isContainer</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdesignercustomwidgetinterface.html#isInitialized">isInitialized</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#name">name</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#toolTip">toolTip</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdesignercustomwidgetinterface.html#whatsThis">whatsThis</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDesignerCustomWidgetInterface class enables Qt Designer to
access and construct custom widgets.</p>
<p>QDesignerCustomWidgetInterface provides a custom widget with an
interface. The class contains a set of functions that must be
subclassed to return basic information about the widget, such as
its class name and the name of its header file. Other functions
must be implemented to initialize the plugin when it is loaded, and
to construct instances of the custom widget for <i>Qt Designer</i>
to use.</p>
<p>When implementing a custom widget you must subclass
QDesignerCustomWidgetInterface to expose your widget to <i>Qt
Designer</i>. For example, this is the declaration for the plugin
used in the <a href="designer-customwidgetplugin.html">Custom
Widget Plugin example</a> that enables an analog clock custom
widget to be used by <i>Qt Designer</i>:</p>
<pre class="cpp">
 <span class="keyword">class</span> AnalogClockPlugin : <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">QDesignerCustomWidgetInterface</span>
 {
     Q_OBJECT
     Q_INTERFACES(<span class="type">QDesignerCustomWidgetInterface</span>)

 <span class="keyword">public</span>:
     AnalogClockPlugin(<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="type">bool</span> isContainer() <span class="keyword">const</span>;
     <span class="type">bool</span> isInitialized() <span class="keyword">const</span>;
     <span class="type"><a href="qicon.html">QIcon</a></span> icon() <span class="keyword">const</span>;
     <span class="type"><a href="qstring.html">QString</a></span> domXml() <span class="keyword">const</span>;
     <span class="type"><a href="qstring.html">QString</a></span> group() <span class="keyword">const</span>;
     <span class="type"><a href="qstring.html">QString</a></span> includeFile() <span class="keyword">const</span>;
     <span class="type"><a href="qstring.html">QString</a></span> name() <span class="keyword">const</span>;
     <span class="type"><a href="qstring.html">QString</a></span> toolTip() <span class="keyword">const</span>;
     <span class="type"><a href="qstring.html">QString</a></span> whatsThis() <span class="keyword">const</span>;
     <span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>createWidget(<span class="type"><a href="qwidget.html">QWidget</a></span> <span class="operator">*</span>parent);
     <span class="type">void</span> initialize(<span class="type"><a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a></span> <span class="operator">*</span>core);

 <span class="keyword">private</span>:
     <span class="type">bool</span> initialized;
 };
</pre>
<p>Note that the only part of the class definition that is specific
to this particular custom widget is the class name. In addition,
since we are implementing an interface, we must ensure that it's
made known to the meta object system using the <a href="qobject.html#Q_INTERFACES">Q_INTERFACES</a>() macro. This enables
<i>Qt Designer</i> to use the <a href="qobject.html#qobject_cast">qobject_cast</a>() function to query
for supported interfaces using nothing but a <a href="qobject.html">QObject</a> pointer.</p>
<p>After <i>Qt Designer</i> loads a custom widget plugin, it calls
the interface's <a href="qdesignercustomwidgetinterface.html#initialize">initialize</a>()
function to enable it to set up any resources that it may need.
This function is called with a <a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a>
parameter that provides the plugin with a gateway to all of <i>Qt
Designer</i>'s API.</p>
<p><i>Qt Designer</i> constructs instances of the custom widget by
calling the plugin's <a href="qdesignercustomwidgetinterface.html#createWidget">createWidget</a>()
function with a suitable parent widget. Plugins must construct and
return an instance of a custom widget with the specified parent
widget.</p>
<p>In the implementation of the class you must remember to export
your custom widget plugin to <i>Qt Designer</i> using the <a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a>() macro. For
example, if a library called <tt>libcustomwidgetplugin.so</tt> (on
Unix) or <tt>libcustomwidget.dll</tt> (on Windows) contains a
widget class called <tt>MyCustomWidget</tt>, we can export it by
adding the following line to the file containing the plugin
implementation:</p>
<pre class="cpp">
 <a href="qtplugin.html#Q_EXPORT_PLUGIN2">Q_EXPORT_PLUGIN2</a>(customwidgetplugin<span class="operator">,</span> MyCustomWidget)
</pre>
<p>This macro ensures that <i>Qt Designer</i> can access and
construct the custom widget. Without this macro, there is no way
for <i>Qt Designer</i> to use it.</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 <a href="qdesignercustomwidgetcollectioninterface.html">QDesignerCustomWidgetCollectionInterface</a>.</p>
<p><b>Warning:</b> If your custom widget plugin contains <a href="qvariant.html">QVariant</a> properties, be aware that only the
following <a href="qvariant.html#Type-enum">types</a> are
supported:</p>
<ul>
<li><a href="qvariant.html#Type-enum">QVariant.ByteArray</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Bool</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Color</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Cursor</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Date</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.DateTime</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Double</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Int</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Point</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Rect</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Size</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.SizePolicy</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.String</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.Time</a></li>
<li><a href="qvariant.html#Type-enum">QVariant.UInt</a></li>
</ul>
<p>For a complete example using the QDesignerCustomWidgetInterface
class, see the <a href="designer-customwidgetplugin.html">Custom
Widget Example</a>. The example shows how to create a custom widget
plugin for <i>Qt Designer</i>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDesignerCustomWidgetInterface" />QDesignerCustomWidgetInterface.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QDesignerCustomWidgetInterface-2" />QDesignerCustomWidgetInterface.__init__ (<i>self</i>, <a href="qdesignercustomwidgetinterface.html">QDesignerCustomWidgetInterface</a>)</h3><h3 class="fn"><a name="codeTemplate" />QString QDesignerCustomWidgetInterface.codeTemplate (<i>self</i>)</h3><p>This function is reserved for future use by <i>Qt
Designer</i>.</p>


<h3 class="fn"><a name="createWidget" /><a href="qwidget.html">QWidget</a> QDesignerCustomWidgetInterface.createWidget (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Returns a new instance of the custom widget, with the given
<i>parent</i>.</p>


<h3 class="fn"><a name="domXml" />QString QDesignerCustomWidgetInterface.domXml (<i>self</i>)</h3><p>Returns the XML that is used to describe the custom widget's
properties to <i>Qt Designer</i>.</p>


<h3 class="fn"><a name="group" />QString QDesignerCustomWidgetInterface.group (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the name of the group to which the custom widget
belongs.</p>


<h3 class="fn"><a name="icon" /><a href="qicon.html">QIcon</a> QDesignerCustomWidgetInterface.icon (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the icon used to represent the custom widget in <i>Qt
Designer</i>'s widget box.</p>


<h3 class="fn"><a name="includeFile" />QString QDesignerCustomWidgetInterface.includeFile (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the path to the include file that <a href="uic.html#uic">uic</a> uses when creating code for the custom
widget.</p>


<h3 class="fn"><a name="initialize" />QDesignerCustomWidgetInterface.initialize (<i>self</i>, <a href="qdesignerformeditorinterface.html">QDesignerFormEditorInterface</a>&#160;<i>core</i>)</h3><p>Initializes the widget for use with the specified
<i>formEditor</i> interface.</p>
<p><b>See also</b> <a href="qdesignercustomwidgetinterface.html#isInitialized">isInitialized</a>().</p>


<h3 class="fn"><a name="isContainer" />bool QDesignerCustomWidgetInterface.isContainer (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns true if the custom widget is intended to be used as a
container; otherwise returns false.</p>
<p>Most custom widgets are not used to hold other widgets, so their
implementations of this function will return false, but custom
containers will return true to ensure that they behave correctly in
<i>Qt Designer</i>.</p>


<h3 class="fn"><a name="isInitialized" />bool QDesignerCustomWidgetInterface.isInitialized (<i>self</i>)</h3><p>Returns true if the widget has been initialized; otherwise
returns false.</p>
<p><b>See also</b> <a href="qdesignercustomwidgetinterface.html#initialize">initialize</a>().</p>


<h3 class="fn"><a name="name" />QString QDesignerCustomWidgetInterface.name (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the class name of the custom widget supplied by the
interface.</p>
<p>The name returned <i>must</i> be identical to the class name
used for the custom widget.</p>


<h3 class="fn"><a name="toolTip" />QString QDesignerCustomWidgetInterface.toolTip (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns a short description of the widget that can be used by
<i>Qt Designer</i> in a tool tip.</p>


<h3 class="fn"><a name="whatsThis" />QString QDesignerCustomWidgetInterface.whatsThis (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns a description of the widget that can be used by <i>Qt
Designer</i> in "What's This?" help for the widget.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>