This file is indexed.

/usr/share/qt5/doc/qtdesigner/qdesignertaskmenuextension.html is in qttools5-doc-html 5.2.1-8build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- taskmenu.qdoc -->
  <title>QDesignerTaskMenuExtension Class | QtDesigner </title>
  <link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
    <div class="main">
    <div class="main-rounded">
        <div class="navigationbar">
        <ul>
<li>Qt 5.2</li>
<li><a href="qtdesigner-manual.html">Qt Designer Manual</a></li>
<li><a href="qtdesigner-module.html">C++ Classes</a></li>
<li>QDesignerTaskMenuExtension</li>
<li id="buildversion">
Qt 5.2.1 Reference Documentation</li>
    </ul>
    </div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QDesignerTaskMenuExtension Class</h1>
<!-- $$$QDesignerTaskMenuExtension-brief -->
<p>The QDesignerTaskMenuExtension class allows you to add custom menu entries to Qt Designer's task menu. <a href="#details">More...</a></p>
<!-- @@@QDesignerTaskMenuExtension -->
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> </b><tt><span class="preprocessor">#include &lt;QDesignerTaskMenuExtension&gt;</span>
</tt></td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> <tt>QT += designer</tt></td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p></p>
</td></tr></table><ul>
<li><a href="qdesignertaskmenuextension-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qdesignertaskmenuextension.html#dtor.QDesignerTaskMenuExtension">~QDesignerTaskMenuExtension</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QAction * </td><td class="memItemRight bottomAlign"><b><a href="qdesignertaskmenuextension.html#preferredEditAction">preferredEditAction</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QList&lt;QAction *&gt; </td><td class="memItemRight bottomAlign"><b><a href="qdesignertaskmenuextension.html#taskActions">taskActions</a></b>() const = 0</td></tr>
</table>
<a name="details"></a>
<!-- $$$QDesignerTaskMenuExtension-description -->
<div class="descr">
<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" alt="" /></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..&#x2e;</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="../qtcore/qobject.html">QObject</a> and QDesignerTaskMenuExtension. For example:</p>
<pre class="cpp"><span class="keyword">class</span> MyTaskMenuExtension : <span class="keyword">public</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span><span class="operator">,</span>
        <span class="keyword">public</span> <span class="type">QDesignerTaskMenuExtension</span>
{
    Q_OBJECT
    Q_INTERFACES(<span class="type">QDesignerTaskMenuExtension</span>)

<span class="keyword">public</span>:
    MyTaskMenuExtension(MyCustomWidget <span class="operator">*</span>widget<span class="operator">,</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>parent);

    <span class="type"><a href="../qtwidgets/qaction.html">QAction</a></span> <span class="operator">*</span>preferredEditAction() <span class="keyword">const</span>;
    <span class="type"><a href="../qtcore/qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qaction.html">QAction</a></span> <span class="operator">*</span><span class="operator">&gt;</span> taskActions() <span class="keyword">const</span>;

<span class="keyword">private</span> <span class="keyword">slots</span>:
    <span class="type">void</span> mySlot();

<span class="keyword">private</span>:
    MyCustomWidget <span class="operator">*</span>widget;
    <span class="type"><a href="../qtwidgets/qaction.html">QAction</a></span> <span class="operator">*</span>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="../qtcore/qobject.html#Q_INTERFACES">Q_INTERFACES</a>() macro. This enables <i>Qt Designer</i> to use the <a href="../qtcore/qobject.html#qobject_cast">qobject_cast</a>() function to query for supported interfaces using nothing but a <a href="../qtcore/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="cpp"><span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>ANewExtensionFactory<span class="operator">::</span>createExtension(<span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>object<span class="operator">,</span>
        <span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>iid<span class="operator">,</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>parent) <span class="keyword">const</span>
{
    <span class="keyword">if</span> (iid <span class="operator">!</span><span class="operator">=</span> Q_TYPEID(<span class="type">QDesignerTaskMenuExtension</span>))
        <span class="keyword">return</span> <span class="number">0</span>;

    <span class="keyword">if</span> (MyCustomWidget <span class="operator">*</span>widget <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span>MyCustomWidget<span class="operator">*</span><span class="operator">&gt;</span>(object))
        <span class="keyword">return</span> <span class="keyword">new</span> MyTaskMenuExtension(widget<span class="operator">,</span> parent);

    <span class="keyword">return</span> <span class="number">0</span>;
}</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="cpp"><span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>AGeneralExtensionFactory<span class="operator">::</span>createExtension(<span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>object<span class="operator">,</span>
        <span class="keyword">const</span> <span class="type"><a href="../qtcore/qstring.html">QString</a></span> <span class="operator">&amp;</span>iid<span class="operator">,</span> <span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>parent) <span class="keyword">const</span>
{
    MyCustomWidget <span class="operator">*</span>widget <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span>MyCustomWidget<span class="operator">*</span><span class="operator">&gt;</span>(object);

    <span class="keyword">if</span> (widget <span class="operator">&amp;</span><span class="operator">&amp;</span> (iid <span class="operator">=</span><span class="operator">=</span> Q_TYPEID(<span class="type"><a href="qdesignercontainerextension.html">QDesignerContainerExtension</a></span>))) {
        <span class="keyword">return</span> <span class="keyword">new</span> MyContainerExtension(widget<span class="operator">,</span> parent);

    } <span class="keyword">else</span> <span class="keyword">if</span> (widget <span class="operator">&amp;</span><span class="operator">&amp;</span> (iid <span class="operator">=</span><span class="operator">=</span> Q_TYPEID(<span class="type">QDesignerTaskMenuExtension</span>))) {
        <span class="keyword">return</span> <span class="keyword">new</span> MyTaskMenuExtension(widget<span class="operator">,</span> parent);

    } <span class="keyword">else</span> {
        <span class="keyword">return</span> <span class="number">0</span>;
    }
}</pre>
<p>For a complete example using the QDesignerTaskMenuExtension class, see the <a href="qtdesigner-taskmenuextension-example.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>
</div>
<p><b>See also </b><a href="qextensionfactory.html">QExtensionFactory</a>, <a href="qextensionmanager.html">QExtensionManager</a>, and <a href="designer-creating-custom-widgets-extensions.html">Creating Custom Widget Extensions</a>.</p>
<!-- @@@QDesignerTaskMenuExtension -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$~QDesignerTaskMenuExtension[overload1]$$$~QDesignerTaskMenuExtension -->
<h3 class="fn"><a name="dtor.QDesignerTaskMenuExtension"></a>QDesignerTaskMenuExtension::<span class="name">~QDesignerTaskMenuExtension</span>()<tt> [virtual]</tt></h3>
<p>Destroys the task menu extension.</p>
<!-- @@@~QDesignerTaskMenuExtension -->
<!-- $$$preferredEditAction[overload1]$$$preferredEditAction -->
<h3 class="fn"><a name="preferredEditAction"></a><span class="type"><a href="../qtwidgets/qaction.html">QAction</a></span> * QDesignerTaskMenuExtension::<span class="name">preferredEditAction</span>() const<tt> [virtual]</tt></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>
<!-- @@@preferredEditAction -->
<!-- $$$taskActions[overload1]$$$taskActions -->
<h3 class="fn"><a name="taskActions"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span>&lt;<span class="type"><a href="../qtwidgets/qaction.html">QAction</a></span> *&gt; QDesignerTaskMenuExtension::<span class="name">taskActions</span>() const<tt> [pure virtual]</tt></h3>
<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>
<!-- @@@taskActions -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2013 Digia Plc and/or its
   subsidiaries. Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Digia, Qt and their respective logos are trademarks of Digia Plc     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>