Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > e63754dc5af9f9ec95223fcea9485104 > files > 1454

python3-PyQt4-devel-4.8.3-2.fc14.x86_64.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>QDesignerTaskMenuExtension 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="../pyqt4ref.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">QDesignerTaskMenuExtension Class Reference<br /><sup><sup>[<a href="qtdesigner.html">QtDesigner</a> module]</sup></sup></h1><p>The QDesignerTaskMenuExtension class allows you to add custom
menu entries to Qt Designer's task menu. <a href="#details">More...</a></p>

<p>Inherited by <a href="qpydesignertaskmenuextension.html">QPyDesignerTaskMenuExtension</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdesignertaskmenuextension.html#QDesignerTaskMenuExtension">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdesignertaskmenuextension.html#QDesignerTaskMenuExtension-2">__init__</a></b> (<i>self</i>, QDesignerTaskMenuExtension)</li><li><div class="fn" />QAction <b><a href="qdesignertaskmenuextension.html#preferredEditAction">preferredEditAction</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QAction <b><a href="qdesignertaskmenuextension.html#taskActions">taskActions</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDesignerTaskMenuExtension class allows you to add custom
menu entries to Qt Designer's task menu.</p>
<p>QDesignerTaskMenuExtension provides an interface for creating
custom task menu extensions. It is typically used to create task
menu entries that are specific to a plugin in <i>Qt
Designer</i>.</p>
<p><i>Qt Designer</i> uses the QDesignerTaskMenuExtension to feed
its task menu. Whenever a task menu is requested, <i>Qt
Designer</i> will query for the selected widget's task menu
extension.</p>
<p class="centerAlign"><img src="images/taskmenuextension-example-faded.png" /></p>
<p>A task menu extension is a collection of QActions. The actions
appear as entries in the task menu when the plugin with the
specified extension is selected. The image above shows the custom
<b>Edit State...</b> action which appears in addition to <i>Qt
Designer</i>'s default task menu entries: <b>Cut</b>, <b>Copy</b>,
<b>Paste</b> etc.</p>
<p>To create a custom task menu extension, your extension class
must inherit from both <a href="qobject.html">QObject</a> and
QDesignerTaskMenuExtension. For example:</p>
<pre class="highlightedCode brush: cpp">
 class MyTaskMenuExtension : public QObject,
         public QDesignerTaskMenuExtension
 {
     Q_OBJECT
     Q_INTERFACES(QDesignerTaskMenuExtension)

 public:
     MyTaskMenuExtension(MyCustomWidget *widget, QObject *parent);

     QAction *preferredEditAction() const;
     QList&lt;QAction *&gt; taskActions() const;

 private slots:
     void mySlot();

 private:
     MyCustomWidget *widget;
     QAction *myAction;
 };
</pre>
<p>Since we are implementing an interface, we must ensure that it
is 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>You must reimplement the <a href="qdesignertaskmenuextension.html#taskActions">taskActions</a>()
function to return a list of actions that will be included in <i>Qt
Designer</i> task menu. Optionally, you can reimplement the
<a href="qdesignertaskmenuextension.html#preferredEditAction">preferredEditAction</a>()
function to set the action that is invoked when selecting your
plugin and pressing <b>F2</b>. The preferred edit action must be
one of the actions returned by <a href="qdesignertaskmenuextension.html#taskActions">taskActions</a>()
and, if it's not defined, pressing the <b>F2</b> key will simply be
ignored.</p>
<p>In <i>Qt Designer</i>, extensions are not created until they are
required. A task menu extension, for example, is created when you
click the right mouse button over a widget in <i>Qt Designer</i>'s
workspace. For that reason you must also construct an extension
factory, using either <a href="qextensionfactory.html">QExtensionFactory</a> or a subclass, and
register it using <i>Qt Designer</i>'s <a href="qextensionmanager.html">extension manager</a>.</p>
<p>When a task menu extension is required, <i>Qt Designer</i>'s
<a href="qextensionmanager.html">extension manager</a> will run
through all its registered factories calling <a href="qextensionfactory.html#createExtension">QExtensionFactory.createExtension</a>()
for each until it finds one that is able to create a task menu
extension for the selected widget. This factory will then make an
instance of the extension.</p>
<p>There are four available types of extensions in <i>Qt
Designer</i>: <a href="qdesignercontainerextension.html">QDesignerContainerExtension</a>,
<a href="qdesignermembersheetextension.html">QDesignerMemberSheetExtension</a>,
<a href="qdesignerpropertysheetextension.html">QDesignerPropertySheetExtension</a>,
and QDesignerTaskMenuExtension. <i>Qt Designer</i>'s behavior is
the same whether the requested extension is associated with a
container, a member sheet, a property sheet or a task menu.</p>
<p>The <a href="qextensionfactory.html">QExtensionFactory</a> class
provides a standard extension factory, and can also be used as an
interface for custom extension factories. You can either create a
new <a href="qextensionfactory.html">QExtensionFactory</a> and
reimplement the <a href="qextensionfactory.html#createExtension">QExtensionFactory.createExtension</a>()
function. For example:</p>
<pre class="highlightedCode brush: cpp">
 QObject *ANewExtensionFactory.createExtension(QObject *object,
         const QString &amp;iid, QObject *parent) const
 {
     if (iid != Q_TYPEID(QDesignerTaskMenuExtension))
         return 0;

     if (MyCustomWidget *widget = qobject_cast&lt;MyCustomWidget*&gt;(object))
         return new MyTaskMenuExtension(widget, parent);

     return 0;
 }
</pre>
<p>Or you can use an existing factory, expanding the <a href="qextensionfactory.html#createExtension">QExtensionFactory.createExtension</a>()
function to make the factory able to create a task menu extension
as well. For example:</p>
<pre class="highlightedCode brush: cpp">
 QObject *AGeneralExtensionFactory.createExtension(QObject *object,
         const QString &amp;iid, QObject *parent) const
 {
     MyCustomWidget *widget = qobject_cast&lt;MyCustomWidget*&gt;(object);

     if (widget &amp;&amp; (iid == Q_TYPEID(QDesignerContainerExtension))) {
         return new MyContainerExtension(widget, parent);

     } else if (widget &amp;&amp; (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
         return new MyTaskMenuExtension(widget, parent);

     } else {
         return 0;
     }
 }
</pre>
<p>For a complete example using the QDesignerTaskMenuExtension
class, see the <a href="designer-taskmenuextension.html">Task Menu
Extension example</a>. The example shows how to create a custom
widget plugin for <i>Qt Designer</i>, and how to to use the
QDesignerTaskMenuExtension class to add custom items to <i>Qt
Designer</i>'s task menu.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDesignerTaskMenuExtension" />QDesignerTaskMenuExtension.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QDesignerTaskMenuExtension-2" />QDesignerTaskMenuExtension.__init__ (<i>self</i>, <a href="qdesignertaskmenuextension.html">QDesignerTaskMenuExtension</a>)</h3><h3 class="fn"><a name="preferredEditAction" /><a href="qaction.html">QAction</a> QDesignerTaskMenuExtension.preferredEditAction (<i>self</i>)</h3><p>Returns the action that is invoked when selecting a plugin with
the specified extension and pressing <b>F2</b>.</p>
<p>The action must be one of the actions returned by <a href="qdesignertaskmenuextension.html#taskActions">taskActions</a>().</p>


<h3 class="fn"><a name="taskActions" />list-of-QAction QDesignerTaskMenuExtension.taskActions (<i>self</i>)</h3><p>This method is abstract and should be reimplemented in any sub-class.</p><p>Returns the task menu extension as a list of actions which will
be included in <i>Qt Designer</i>'s task menu when a plugin with
the specified extension is selected.</p>
<p>The function must be reimplemented to add actions to the
list.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.8.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> 2011</td><td align="right" width="25%">Qt&#160;4.7.1</td></tr></table></div></address></body></html>