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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
<?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>QMetaMethod 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">QMetaMethod Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QMetaMethod class provides meta-data about a member
function. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qmetamethod.html#Access-enum">Access</a></b> { Private, Protected, Public }</li><li><div class="fn" />enum <b><a href="qmetamethod.html#MethodType-enum">MethodType</a></b> { Method, Signal, Slot, Constructor }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qmetamethod.html#QMetaMethod">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qmetamethod.html#QMetaMethod-2">__init__</a></b> (<i>self</i>, QMetaMethod)</li><li><div class="fn" />Access <b><a href="qmetamethod.html#access">access</a></b> (<i>self</i>)</li><li><div class="fn" />object <b><a href="qmetamethod.html#invoke">invoke</a></b> (<i>self</i>, QObject <i>object</i>, Qt.ConnectionType <i>connectionType</i>, QGenericReturnArgument <i>returnValue</i>, QGenericArgument <i>value0</i> = QGenericArgument(0,0), QGenericArgument <i>value1</i> = QGenericArgument(0,0), QGenericArgument <i>value2</i> = QGenericArgument(0,0), QGenericArgument <i>value3</i> = QGenericArgument(0,0), QGenericArgument <i>value4</i> = QGenericArgument(0,0), QGenericArgument <i>value5</i> = QGenericArgument(0,0), QGenericArgument <i>value6</i> = QGenericArgument(0,0), QGenericArgument <i>value7</i> = QGenericArgument(0,0), QGenericArgument <i>value8</i> = QGenericArgument(0,0), QGenericArgument <i>value9</i> = QGenericArgument(0,0))</li><li><div class="fn" />object <b><a href="qmetamethod.html#invoke-2">invoke</a></b> (<i>self</i>, QObject <i>object</i>, QGenericReturnArgument <i>returnValue</i>, QGenericArgument <i>value0</i> = QGenericArgument(0,0), QGenericArgument <i>value1</i> = QGenericArgument(0,0), QGenericArgument <i>value2</i> = QGenericArgument(0,0), QGenericArgument <i>value3</i> = QGenericArgument(0,0), QGenericArgument <i>value4</i> = QGenericArgument(0,0), QGenericArgument <i>value5</i> = QGenericArgument(0,0), QGenericArgument <i>value6</i> = QGenericArgument(0,0), QGenericArgument <i>value7</i> = QGenericArgument(0,0), QGenericArgument <i>value8</i> = QGenericArgument(0,0), QGenericArgument <i>value9</i> = QGenericArgument(0,0))</li><li><div class="fn" />object <b><a href="qmetamethod.html#invoke-3">invoke</a></b> (<i>self</i>, QObject <i>object</i>, Qt.ConnectionType <i>connectionType</i>, QGenericArgument <i>value0</i> = QGenericArgument(0,0), QGenericArgument <i>value1</i> = QGenericArgument(0,0), QGenericArgument <i>value2</i> = QGenericArgument(0,0), QGenericArgument <i>value3</i> = QGenericArgument(0,0), QGenericArgument <i>value4</i> = QGenericArgument(0,0), QGenericArgument <i>value5</i> = QGenericArgument(0,0), QGenericArgument <i>value6</i> = QGenericArgument(0,0), QGenericArgument <i>value7</i> = QGenericArgument(0,0), QGenericArgument <i>value8</i> = QGenericArgument(0,0), QGenericArgument <i>value9</i> = QGenericArgument(0,0))</li><li><div class="fn" />object <b><a href="qmetamethod.html#invoke-4">invoke</a></b> (<i>self</i>, QObject <i>object</i>, QGenericArgument <i>value0</i> = QGenericArgument(0,0), QGenericArgument <i>value1</i> = QGenericArgument(0,0), QGenericArgument <i>value2</i> = QGenericArgument(0,0), QGenericArgument <i>value3</i> = QGenericArgument(0,0), QGenericArgument <i>value4</i> = QGenericArgument(0,0), QGenericArgument <i>value5</i> = QGenericArgument(0,0), QGenericArgument <i>value6</i> = QGenericArgument(0,0), QGenericArgument <i>value7</i> = QGenericArgument(0,0), QGenericArgument <i>value8</i> = QGenericArgument(0,0), QGenericArgument <i>value9</i> = QGenericArgument(0,0))</li><li><div class="fn" />int <b><a href="qmetamethod.html#methodIndex">methodIndex</a></b> (<i>self</i>)</li><li><div class="fn" />MethodType <b><a href="qmetamethod.html#methodType">methodType</a></b> (<i>self</i>)</li><li><div class="fn" />unknown-type <b><a href="qmetamethod.html#parameterNames">parameterNames</a></b> (<i>self</i>)</li><li><div class="fn" />unknown-type <b><a href="qmetamethod.html#parameterTypes">parameterTypes</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qmetamethod.html#signature">signature</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qmetamethod.html#tag">tag</a></b> (<i>self</i>)</li><li><div class="fn" />str <b><a href="qmetamethod.html#typeName">typeName</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QMetaMethod class provides meta-data about a member
function.</p>
<p>A QMetaMethod has a <a href="qmetamethod.html#methodType">methodType</a>(), a <a href="qmetamethod.html#signature">signature</a>(), a list of <a href="qmetamethod.html#parameterTypes">parameterTypes</a>() and <a href="qmetamethod.html#parameterNames">parameterNames</a>(), a return
<a href="qmetamethod.html#typeName">typeName</a>(), a <a href="qmetamethod.html#tag">tag</a>(), and an <a href="qmetamethod.html#access">access</a>() specifier. You can use
<a href="qmetamethod.html#invoke">invoke</a>() to invoke the method
on an arbitrary <a href="qobject.html">QObject</a>.</p>
<p>A method will only be registered with the meta-object system if
it is a slot, a signal, or declared with the <a href="qobject.html#Q_INVOKABLE">Q_INVOKABLE</a> macro. Constructors can
also be registered with <a href="qobject.html#Q_INVOKABLE">Q_INVOKABLE</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Access-enum" />QMetaMethod.Access</h3><p>This enum describes the access level of a method, following the
conventions used in C++.</p>
<table class="valuelist">
<tr>
<th class="tblConst">Constant</th>
<th class="tblVal">Value</th>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Private</tt></td>
<td class="topAlign"><tt>0</tt></td>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Protected</tt></td>
<td class="topAlign"><tt>1</tt></td>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Public</tt></td>
<td class="topAlign"><tt>2</tt></td>
</tr>
</table>
<h3 class="fn"><a name="MethodType-enum" />QMetaMethod.MethodType</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Method</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">The function is a plain member function.</td>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Signal</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">The function is a signal.</td>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Slot</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">The function is a slot.</td>
</tr>
<tr>
<td class="topAlign"><tt>QMetaMethod.Constructor</tt></td>
<td class="topAlign"><tt>3</tt></td>
<td class="topAlign">The function is a constructor.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QMetaMethod" />QMetaMethod.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QMetaMethod-2" />QMetaMethod.__init__ (<i>self</i>, <a href="qmetamethod.html">QMetaMethod</a>)</h3><h3 class="fn"><a name="access" /><a href="qmetamethod.html#Access-enum">Access</a> QMetaMethod.access (<i>self</i>)</h3><p>Returns the access specification of this method (private,
protected, or public).</p>
<p>Signals are always protected, meaning that you can only emit
them from the class or from a subclass.</p>
<p><b>See also</b> <a href="qmetamethod.html#methodType">methodType</a>().</p>
<h3 class="fn"><a name="invoke" />object QMetaMethod.invoke (<i>self</i>, <a href="qobject.html">QObject</a> <i>object</i>, <a href="qt.html#ConnectionType-enum">Qt.ConnectionType</a> <i>connectionType</i>, <a href="qgenericreturnargument.html">QGenericReturnArgument</a> <i>returnValue</i>, <a href="qgenericargument.html">QGenericArgument</a> <i>value0</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value1</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value2</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value3</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value4</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value5</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value6</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value7</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value8</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value9</i> = QGenericArgument(0,0))</h3><p>Invokes this method on the object <i>object</i>. Returns true if
the member could be invoked. Returns false if there is no such
member or the parameters did not match.</p>
<p>The invocation can be either synchronous or asynchronous,
depending on the <i>connectionType</i>:</p>
<ul>
<li>If <i>connectionType</i> is <a href="qt.html#ConnectionType-enum">Qt.DirectConnection</a>, the member
will be invoked immediately.</li>
<li>If <i>connectionType</i> is <a href="qt.html#ConnectionType-enum">Qt.QueuedConnection</a>, a <a href="qevent.html">QEvent</a> will be posted and the member is invoked
as soon as the application enters the main event loop.</li>
<li>If <i>connectionType</i> is <a href="qt.html#ConnectionType-enum">Qt.AutoConnection</a>, the member is
invoked synchronously if <i>object</i> lives in the same thread as
the caller; otherwise it will invoke the member
asynchronously.</li>
</ul>
<p>The return value of this method call is placed in
<i>returnValue</i>. If the invocation is asynchronous, the return
value cannot be evaluated. You can pass up to ten arguments
(<i>val0</i>, <i>val1</i>, <i>val2</i>, <i>val3</i>, <i>val4</i>,
<i>val5</i>, <i>val6</i>, <i>val7</i>, <i>val8</i>, and
<i>val9</i>) to this method call.</p>
<p><a href="qgenericargument.html">QGenericArgument</a> and
<a href="qgenericreturnargument.html">QGenericReturnArgument</a>
are internal helper classes. Because signals and slots can be
dynamically invoked, you must enclose the arguments using the
<a href="qmetaobject.html#Q_ARG">Q_ARG</a>() and <a href="qmetaobject.html#Q_RETURN_ARG">Q_RETURN_ARG</a>() macros. <a href="qmetaobject.html#Q_ARG">Q_ARG</a>() takes a type name and a const
reference of that type; <a href="qmetaobject.html#Q_RETURN_ARG">Q_RETURN_ARG</a>() takes a type
name and a non-const reference.</p>
<p>To asynchronously invoke the <a href="qabstractbutton.html#animateClick">animateClick()</a> slot on a
<a href="qpushbutton.html">QPushButton</a>:</p>
<pre class="cpp">
<span class="type">int</span> methodIndex <span class="operator">=</span> pushButton<span class="operator">-</span><span class="operator">></span>metaObject()<span class="operator">-</span><span class="operator">></span>indexOfMethod(<span class="string">"animateClick()"</span>);
<span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> method <span class="operator">=</span> metaObject<span class="operator">-</span><span class="operator">></span>method(methodIndex);
method<span class="operator">.</span>invoke(pushButton<span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>QueuedConnection);
</pre>
<p>With asynchronous method invocations, the parameters must be of
types that are known to Qt's meta-object system, because Qt needs
to copy the arguments to store them in an event behind the scenes.
If you try to use a queued connection and get the error message</p>
<pre class="cpp">
<span class="type"><a href="qmetamethod.html">QMetaMethod</a></span><span class="operator">.</span>invoke: Unable to handle unregistered datatype <span class="char">'MyType'</span>
</pre>
<p>call <a href="qmetatype.html#qRegisterMetaType">qRegisterMetaType</a>() to
register the data type before you call QMetaMethod.invoke().</p>
<p>To synchronously invoke the <tt>compute(QString, int,
double)</tt> slot on some arbitrary object <tt>obj</tt> retrieve
its return value:</p>
<pre class="cpp">
<span class="type"><a href="qstring.html">QString</a></span> retVal;
<span class="type"><a href="qbytearray.html">QByteArray</a></span> normalizedSignature <span class="operator">=</span> <span class="type"><a href="qmetaobject.html">QMetaObject</a></span><span class="operator">.</span>normalizedSignature(<span class="string">"compute(QString, int, double)"</span>);
<span class="type">int</span> methodIndex <span class="operator">=</span> obj<span class="operator">-</span><span class="operator">></span>metaObject()<span class="operator">-</span><span class="operator">></span>indexOfMethod(normalizedSignature);
<span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> method <span class="operator">=</span> metaObject<span class="operator">-</span><span class="operator">></span>method(methodIndex);
method<span class="operator">.</span>invoke(obj<span class="operator">,</span>
<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>DirectConnection<span class="operator">,</span>
Q_RETURN_ARG(<span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> retVal)<span class="operator">,</span>
Q_ARG(<span class="type"><a href="qstring.html">QString</a></span><span class="operator">,</span> <span class="string">"sqrt"</span>)<span class="operator">,</span>
Q_ARG(<span class="type">int</span><span class="operator">,</span> <span class="number">42</span>)<span class="operator">,</span>
Q_ARG(<span class="type">double</span><span class="operator">,</span> <span class="number">9.7</span>));
</pre>
<p><a href="qmetaobject.html#normalizedSignature">QMetaObject.normalizedSignature</a>()
is used here to ensure that the format of the signature is what
invoke() expects. E.g. extra whitespace is removed.</p>
<p>If the "compute" slot does not take exactly one <a href="qstring.html">QString</a>, one int and one double in the specified
order, the call will fail.</p>
<p><b>Warning:</b> this method will not test the validity of the
arguments: <i>object</i> must be an instance of the class of the
<a href="qmetaobject.html">QMetaObject</a> of which this <a href="qmetamethod.html">QMetaMethod</a> has been constructed with. The
arguments must have the same type as the ones expected by the
method, else, the behaviour is undefined.</p>
<p><b>See also</b> <a href="qmetaobject.html#Q_ARG">Q_ARG</a>(),
<a href="qmetaobject.html#Q_RETURN_ARG">Q_RETURN_ARG</a>(),
<a href="qmetatype.html#qRegisterMetaType">qRegisterMetaType</a>(),
and <a href="qmetaobject.html#invokeMethod">QMetaObject.invokeMethod</a>().</p>
<h3 class="fn"><a name="invoke-2" />object QMetaMethod.invoke (<i>self</i>, <a href="qobject.html">QObject</a> <i>object</i>, <a href="qgenericreturnargument.html">QGenericReturnArgument</a> <i>returnValue</i>, <a href="qgenericargument.html">QGenericArgument</a> <i>value0</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value1</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value2</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value3</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value4</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value5</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value6</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value7</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value8</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value9</i> = QGenericArgument(0,0))</h3><p>This function overloads <a href="qmetamethod.html#invoke">invoke</a>().</p>
<p>This overload always invokes this method using the connection
type <a href="qt.html#ConnectionType-enum">Qt.AutoConnection</a>.</p>
<h3 class="fn"><a name="invoke-3" />object QMetaMethod.invoke (<i>self</i>, <a href="qobject.html">QObject</a> <i>object</i>, <a href="qt.html#ConnectionType-enum">Qt.ConnectionType</a> <i>connectionType</i>, <a href="qgenericargument.html">QGenericArgument</a> <i>value0</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value1</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value2</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value3</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value4</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value5</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value6</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value7</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value8</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value9</i> = QGenericArgument(0,0))</h3><p>This function overloads <a href="qmetamethod.html#invoke">invoke</a>().</p>
<p>This overload can be used if the return value of the member is
of no interest.</p>
<h3 class="fn"><a name="invoke-4" />object QMetaMethod.invoke (<i>self</i>, <a href="qobject.html">QObject</a> <i>object</i>, <a href="qgenericargument.html">QGenericArgument</a> <i>value0</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value1</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value2</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value3</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value4</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value5</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value6</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value7</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value8</i> = QGenericArgument(0,0), <a href="qgenericargument.html">QGenericArgument</a> <i>value9</i> = QGenericArgument(0,0))</h3><p>This function overloads <a href="qmetamethod.html#invoke">invoke</a>().</p>
<p>This overload invokes this method using the connection type
<a href="qt.html#ConnectionType-enum">Qt.AutoConnection</a> and
ignores return values.</p>
<h3 class="fn"><a name="methodIndex" />int QMetaMethod.methodIndex (<i>self</i>)</h3><p>Returns this method's index.</p>
<p>This function was introduced in Qt 4.6.</p>
<h3 class="fn"><a name="methodType" /><a href="qmetamethod.html#MethodType-enum">MethodType</a> QMetaMethod.methodType (<i>self</i>)</h3><p>Returns the type of this method (signal, slot, or method).</p>
<p><b>See also</b> <a href="qmetamethod.html#access">access</a>().</p>
<h3 class="fn"><a name="parameterNames" />unknown-type QMetaMethod.parameterNames (<i>self</i>)</h3><p>Returns a list of parameter names.</p>
<p><b>See also</b> <a href="qmetamethod.html#parameterTypes">parameterTypes</a>() and <a href="qmetamethod.html#signature">signature</a>().</p>
<h3 class="fn"><a name="parameterTypes" />unknown-type QMetaMethod.parameterTypes (<i>self</i>)</h3><p>Returns a list of parameter types.</p>
<p><b>See also</b> <a href="qmetamethod.html#parameterNames">parameterNames</a>() and <a href="qmetamethod.html#signature">signature</a>().</p>
<h3 class="fn"><a name="signature" />str QMetaMethod.signature (<i>self</i>)</h3><p>Returns the signature of this method (e.g.,
<tt>setValue(double)</tt>).</p>
<p><b>See also</b> <a href="qmetamethod.html#parameterTypes">parameterTypes</a>() and <a href="qmetamethod.html#parameterNames">parameterNames</a>().</p>
<h3 class="fn"><a name="tag" />str QMetaMethod.tag (<i>self</i>)</h3><p>Returns the tag associated with this method.</p>
<p>Tags are special macros recognized by <tt>moc</tt> that make it
possible to add extra information about a method.</p>
<p>Tag information can be added in the following way in the
function declaration:</p>
<pre class="cpp">
<span class="preprocessor">#define THISISTESTTAG // tag text</span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
<span class="keyword">private</span> <span class="keyword">slots</span>:
THISISTESTTAG <span class="type">void</span> testFunc();
</pre>
<p>and the information can be accessed by using:</p>
<pre class="cpp">
MainWindow win;
win<span class="operator">.</span>show();
<span class="type">int</span> functionIndex <span class="operator">=</span> win<span class="operator">.</span>metaObject()<span class="operator">-</span><span class="operator">></span>indexOfSlot(<span class="string">"testFunc()"</span>);
<span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> mm <span class="operator">=</span> metaObject()<span class="operator">-</span><span class="operator">></span>method(functionIndex);
<a href="qtcore.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> mm<span class="operator">.</span>tag(); <span class="comment">// prints THISISTESTTAG</span>
</pre>
<p>For the moment, <tt>moc</tt> doesn't support any special
tags.</p>
<h3 class="fn"><a name="typeName" />str QMetaMethod.typeName (<i>self</i>)</h3><p>Returns the return type of this method, or an empty string if
the return type is <i>void</i>.</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>
|