Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 609

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qobject.cpp -->
  <title>QObject Class | Qt Core 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QObject</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#protected-variables">Protected Variables</a></li>
<li class="level1"><a href="#static-protected-members">Static Protected Members</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#macros">Macros</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#thread-affinity">Thread Affinity</a></li>
<li class="level2"><a href="#no-copy-constructor-or-assignment-operator">No Copy Constructor or Assignment Operator</a></li>
<li class="level2"><a href="#auto-connection">Auto-Connection</a></li>
<li class="level2"><a href="#dynamic-properties">Dynamic Properties</a></li>
<li class="level2"><a href="#internationalization-i18n">Internationalization (I18n)</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QObject Class</h1>
<!-- $$$QObject-brief -->
<p>The <a href="qobject.html">QObject</a> class is the base class of all Qt objects. <a href="#details">More...</a></p>
<!-- @@@QObject -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QObject&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qabstractanimation.html">QAbstractAnimation</a>, <a href="qabstracteventdispatcher.html">QAbstractEventDispatcher</a>, <a href="qabstractitemmodel.html">QAbstractItemModel</a>, <a href="qabstractstate.html">QAbstractState</a>, <a href="qabstracttransition.html">QAbstractTransition</a>, <a href="qcoreapplication.html">QCoreApplication</a>, <a href="qeventloop.html">QEventLoop</a>, <a href="qfileselector.html">QFileSelector</a>, <a href="qfilesystemwatcher.html">QFileSystemWatcher</a>, <a href="qiodevice.html">QIODevice</a>, <a href="qitemselectionmodel.html">QItemSelectionModel</a>, <a href="qlibrary.html">QLibrary</a>, <a href="qmimedata.html">QMimeData</a>, <a href="qobjectcleanuphandler.html">QObjectCleanupHandler</a>, <a href="qpluginloader.html">QPluginLoader</a>, <a href="qsettings.html">QSettings</a>, <a href="qsharedmemory.html">QSharedMemory</a>, <a href="qsignalmapper.html" class="obsolete">QSignalMapper</a>, <a href="qsocketnotifier.html">QSocketNotifier</a>, <a href="qthread.html">QThread</a>, <a href="qthreadpool.html">QThreadPool</a>, <a href="qtimeline.html">QTimeLine</a>, <a href="qtimer.html">QTimer</a>, <a href="qtranslator.html">QTranslator</a>, and <a href="qwineventnotifier.html">QWinEventNotifier</a></p>
</td></tr></table></div><ul>
<li><a href="qobject-members.html">List of all members, including inherited members</a></li>
<li><a href="qobject-obsolete.html">Obsolete members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<p><b>Note:</b> These functions are also thread-safe:</p>
<ul>
<li><a href="qobject.html#connect">connect</a>(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)</li>
<li><a href="qobject.html#connect-2">connect</a>(const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const</li>
<li><a href="qobject.html#connect-3">connect</a>(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)</li>
<li><a href="qobject.html#connect-4">connect</a>(const QObject *sender, PointerToMemberFunction signal, Functor functor)</li>
<li><a href="qobject.html#connect-5">connect</a>(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)</li>
<li><a href="qobject.html#disconnect">disconnect</a>(const QObject *sender, const char *signal, const QObject *receiver, const char *method)</li>
<li><a href="qobject.html#disconnect-2">disconnect</a>(const char *signal, const QObject *receiver, const char *method) const</li>
<li><a href="qobject.html#disconnect-5">disconnect</a>(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)</li>
<li><a href="qobject.html#deleteLater">deleteLater</a>()</li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><a href="qobject.html#objectName-prop">objectName</a></b> : QString</li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#QObject">QObject</a></b>(QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#dtor.QObject">~QObject</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#blockSignals">blockSignals</a></b>(bool <i>block</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QObjectList &amp;</td><td class="memItemRight bottomAlign"><b><a href="qobject.html#children">children</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMetaObject::Connection </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connect-2">connect</a></b>(const QObject *<i>sender</i>, const char *<i>signal</i>, const char *<i>method</i>, Qt::ConnectionType <i>type</i> = Qt::AutoConnection) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnect-2">disconnect</a></b>(const char *<i>signal</i> = nullptr, const QObject *<i>receiver</i> = nullptr, const char *<i>method</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnect-3">disconnect</a></b>(const QObject *<i>receiver</i>, const char *<i>method</i> = nullptr) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#dumpObjectInfo">dumpObjectInfo</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#dumpObjectTree">dumpObjectTree</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QByteArray&gt; </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#dynamicPropertyNames">dynamicPropertyNames</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#event">event</a></b>(QEvent *<i>e</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#eventFilter">eventFilter</a></b>(QObject *<i>watched</i>, QEvent *<i>event</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#findChild">findChild</a></b>(const QString &amp;<i>name</i> = QString(), Qt::FindChildOptions <i>options</i> = Qt::FindChildrenRecursively) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#findChildren">findChildren</a></b>(const QString &amp;<i>name</i> = QString(), Qt::FindChildOptions <i>options</i> = Qt::FindChildrenRecursively) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#findChildren-1">findChildren</a></b>(const QRegExp &amp;<i>regExp</i>, Qt::FindChildOptions <i>options</i> = Qt::FindChildrenRecursively) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#findChildren-2">findChildren</a></b>(const QRegularExpression &amp;<i>re</i>, Qt::FindChildOptions <i>options</i> = Qt::FindChildrenRecursively) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#inherits">inherits</a></b>(const char *<i>className</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#installEventFilter">installEventFilter</a></b>(QObject *<i>filterObj</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#isWidgetType">isWidgetType</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#isWindowType">isWindowType</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#killTimer">killTimer</a></b>(int <i>id</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual const QMetaObject *</td><td class="memItemRight bottomAlign"><b><a href="qobject.html#metaObject">metaObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#moveToThread">moveToThread</a></b>(QThread *<i>targetThread</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#objectName-prop">objectName</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QObject *</td><td class="memItemRight bottomAlign"><b><a href="qobject.html#parent">parent</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#property">property</a></b>(const char *<i>name</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#removeEventFilter">removeEventFilter</a></b>(QObject *<i>obj</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#objectName-prop">setObjectName</a></b>(const QString &amp;<i>name</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#setParent">setParent</a></b>(QObject *<i>parent</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#setProperty">setProperty</a></b>(const char *<i>name</i>, const QVariant &amp;<i>value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#signalsBlocked">signalsBlocked</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#startTimer">startTimer</a></b>(int <i>interval</i>, Qt::TimerType <i>timerType</i> = Qt::CoarseTimer)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#startTimer-1">startTimer</a></b>(std::chrono::milliseconds <i>time</i>, Qt::TimerType <i>timerType</i> = Qt::CoarseTimer)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QThread *</td><td class="memItemRight bottomAlign"><b><a href="qobject.html#thread">thread</a></b>() const</td></tr>
</table></div>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#deleteLater">deleteLater</a></b>()</td></tr>
</table></div>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#destroyed">destroyed</a></b>(QObject *<i>obj</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#objectNameChanged">objectNameChanged</a></b>(const QString &amp;<i>objectName</i>)</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QMetaObject::Connection </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connect">connect</a></b>(const QObject *<i>sender</i>, const char *<i>signal</i>, const QObject *<i>receiver</i>, const char *<i>method</i>, Qt::ConnectionType <i>type</i> = Qt::AutoConnection)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMetaObject::Connection </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connect-1">connect</a></b>(const QObject *<i>sender</i>, const QMetaMethod &amp;<i>signal</i>, const QObject *<i>receiver</i>, const QMetaMethod &amp;<i>method</i>, Qt::ConnectionType <i>type</i> = Qt::AutoConnection)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMetaObject::Connection </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connect-3">connect</a></b>(const QObject *<i>sender</i>, PointerToMemberFunction <i>signal</i>, const QObject *<i>receiver</i>, PointerToMemberFunction <i>method</i>, Qt::ConnectionType <i>type</i> = Qt::AutoConnection)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMetaObject::Connection </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connect-4">connect</a></b>(const QObject *<i>sender</i>, PointerToMemberFunction <i>signal</i>, Functor <i>functor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QMetaObject::Connection </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connect-5">connect</a></b>(const QObject *<i>sender</i>, PointerToMemberFunction <i>signal</i>, const QObject *<i>context</i>, Functor <i>functor</i>, Qt::ConnectionType <i>type</i> = Qt::AutoConnection)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnect">disconnect</a></b>(const QObject *<i>sender</i>, const char *<i>signal</i>, const QObject *<i>receiver</i>, const char *<i>method</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnect-1">disconnect</a></b>(const QObject *<i>sender</i>, const QMetaMethod &amp;<i>signal</i>, const QObject *<i>receiver</i>, const QMetaMethod &amp;<i>method</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnect-4">disconnect</a></b>(const QMetaObject::Connection &amp;<i>connection</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnect-5">disconnect</a></b>(const QObject *<i>sender</i>, PointerToMemberFunction <i>signal</i>, const QObject *<i>receiver</i>, PointerToMemberFunction <i>method</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#tr">tr</a></b>(const char *<i>sourceText</i>, const char *<i>disambiguation</i> = Q_OBJECT, int <i>n</i> = Q_OBJECT)</td></tr>
</table></div>
<a name="protected-functions"></a>
<h2 id="protected-functions">Protected Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#childEvent">childEvent</a></b>(QChildEvent *<i>event</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#connectNotify">connectNotify</a></b>(const QMetaMethod &amp;<i>signal</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#customEvent">customEvent</a></b>(QEvent *<i>event</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#disconnectNotify">disconnectNotify</a></b>(const QMetaMethod &amp;<i>signal</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#isSignalConnected">isSignalConnected</a></b>(const QMetaMethod &amp;<i>signal</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#receivers">receivers</a></b>(const char *<i>signal</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QObject *</td><td class="memItemRight bottomAlign"><b><a href="qobject.html#sender">sender</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#senderSignalIndex">senderSignalIndex</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#timerEvent">timerEvent</a></b>(QTimerEvent *<i>event</i>)</td></tr>
</table></div>
<a name="protected-variables"></a>
<h2 id="protected-variables">Protected Variables</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QScopedPointer&lt;QObjectData&gt; </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#d_ptr-var">d_ptr</a></b></td></tr>
</table></div>
<a name="static-protected-members"></a>
<h2 id="static-protected-members">Static Protected Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#staticQtMetaObject-var">staticQtMetaObject</a></b></td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> typedef </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#QObjectList-typedef">QObjectList</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;T&gt; </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#qFindChildren">qFindChildren</a></b>(const QObject *<i>obj</i>, const QRegExp &amp;<i>regExp</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#qobject_cast">qobject_cast</a></b>(QObject *<i>object</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> T </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#qobject_cast-1">qobject_cast</a></b>(const QObject *<i>object</i>)</td></tr>
</table></div>
<a name="macros"></a>
<h2 id="macros">Macros</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#QT_NO_NARROWING_CONVERSIONS_IN_CONNECT">QT_NO_NARROWING_CONVERSIONS_IN_CONNECT</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_CLASSINFO">Q_CLASSINFO</a></b>(<i>Name</i>, <i>Value</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_DISABLE_COPY">Q_DISABLE_COPY</a></b>(<i>Class</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_EMIT">Q_EMIT</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_ENUM">Q_ENUM</a></b>(<i> ...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_ENUM_NS">Q_ENUM_NS</a></b>(<i> ...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_FLAG">Q_FLAG</a></b>(<i> ...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_FLAG_NS">Q_FLAG_NS</a></b>(<i> ...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_GADGET">Q_GADGET</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_INTERFACES">Q_INTERFACES</a></b>(<i> ...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_INVOKABLE">Q_INVOKABLE</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_NAMESPACE">Q_NAMESPACE</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_OBJECT">Q_OBJECT</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a></b>(<i> ...</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_REVISION">Q_REVISION</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_SET_OBJECT_NAME">Q_SET_OBJECT_NAME</a></b>(<i>Object</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_SIGNAL">Q_SIGNAL</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_SIGNALS">Q_SIGNALS</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_SLOT">Q_SLOT</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qobject.html#Q_SLOTS">Q_SLOTS</a></b></td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QObject-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qobject.html">QObject</a> class is the base class of all Qt objects.</p>
<p><a href="qobject.html">QObject</a> is the heart of the Qt <a href="object.html">Object Model</a>. The central feature in this model is a very powerful mechanism for seamless object communication called <a href="signalsandslots.html">signals and slots</a>. You can connect a signal to a slot with <a href="qobject.html#connect">connect</a>() and destroy the connection with <a href="qobject.html#disconnect">disconnect</a>(). To avoid never ending notification loops you can temporarily block signals with <a href="qobject.html#blockSignals">blockSignals</a>(). The protected functions <a href="qobject.html#connectNotify">connectNotify</a>() and <a href="qobject.html#disconnectNotify">disconnectNotify</a>() make it possible to track connections.</p>
<p>QObjects organize themselves in <a href="objecttrees.html">object trees</a>. When you create a <a href="qobject.html">QObject</a> with another object as parent, the object will automatically add itself to the parent's <a href="qobject.html#children">children</a>() list. The parent takes ownership of the object; i.e&#x2e;, it will automatically delete its children in its destructor. You can look for an object by name and optionally type using <a href="qobject.html#findChild">findChild</a>() or <a href="qobject.html#findChildren">findChildren</a>().</p>
<p>Every object has an <a href="qobject.html#objectName-prop">objectName</a>() and its class name can be found via the corresponding <a href="qobject.html#metaObject">metaObject</a>() (see <a href="qmetaobject.html#className">QMetaObject::className</a>()). You can determine whether the object's class inherits another class in the <a href="qobject.html">QObject</a> inheritance hierarchy by using the <a href="qobject.html#inherits">inherits</a>() function.</p>
<p>When an object is deleted, it emits a <a href="qobject.html#destroyed">destroyed</a>() signal. You can catch this signal to avoid dangling references to QObjects.</p>
<p>QObjects can receive events through <a href="qobject.html#event">event</a>() and filter the events of other objects. See <a href="qobject.html#installEventFilter">installEventFilter</a>() and <a href="qobject.html#eventFilter">eventFilter</a>() for details. A convenience handler, <a href="qobject.html#childEvent">childEvent</a>(), can be reimplemented to catch child events.</p>
<p>Last but not least, <a href="qobject.html">QObject</a> provides the basic timer support in Qt; see <a href="qtimer.html">QTimer</a> for high-level support for timers.</p>
<p>Notice that the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro is mandatory for any object that implements signals, slots or properties. You also need to run the Meta Object Compiler on the source file. We strongly recommend the use of this macro in all subclasses of <a href="qobject.html">QObject</a> regardless of whether or not they actually use signals, slots and properties, since failure to do so may lead certain functions to exhibit strange behavior.</p>
<p>All Qt widgets inherit <a href="qobject.html">QObject</a>. The convenience function <a href="qobject.html#isWidgetType">isWidgetType</a>() returns whether an object is actually a widget. It is much faster than <a href="qobject.html#qobject_cast">qobject_cast</a>&lt;<a href="../qtwidgets/qwidget.html">QWidget</a> *&gt;(<i>obj</i>) or <i>obj</i>-&gt;<a href="qobject.html#inherits">inherits</a>(&quot;<a href="../qtwidgets/qwidget.html">QWidget</a>&quot;).</p>
<p>Some <a href="qobject.html">QObject</a> functions, e.g&#x2e; <a href="qobject.html#children">children</a>(), return a <a href="qobject.html#QObjectList-typedef">QObjectList</a>. <a href="qobject.html#QObjectList-typedef">QObjectList</a> is a typedef for <a href="qlist.html">QList</a>&lt;<a href="qobject.html">QObject</a> *&gt;.</p>
<a name="thread-affinity"></a>
<h3 id="thread-affinity">Thread Affinity</h3>
<p>A <a href="qobject.html">QObject</a> instance is said to have a <i>thread affinity</i>, or that it <i>lives</i> in a certain thread. When a <a href="qobject.html">QObject</a> receives a <a href="qt.html#ConnectionType-enum">queued signal</a> or a <a href="eventsandfilters.html#sending-events">posted event</a>, the slot or event handler will run in the thread that the object lives in.</p>
<p><b>Note: </b>If a <a href="qobject.html">QObject</a> has no thread affinity (that is, if <a href="qobject.html#thread">thread</a>() returns zero), or if it lives in a thread that has no running event loop, then it cannot receive queued signals or posted events.</p><p>By default, a <a href="qobject.html">QObject</a> lives in the thread in which it is created. An object's thread affinity can be queried using <a href="qobject.html#thread">thread</a>() and changed using <a href="qobject.html#moveToThread">moveToThread</a>().</p>
<p>All QObjects must live in the same thread as their parent. Consequently:</p>
<ul>
<li><a href="qobject.html#setParent">setParent</a>() will fail if the two QObjects involved live in different threads.</li>
<li>When a <a href="qobject.html">QObject</a> is moved to another thread, all its children will be automatically moved too.</li>
<li><a href="qobject.html#moveToThread">moveToThread</a>() will fail if the <a href="qobject.html">QObject</a> has a parent.</li>
<li>If QObjects are created within <a href="qthread.html#run">QThread::run</a>(), they cannot become children of the <a href="qthread.html">QThread</a> object because the <a href="qthread.html">QThread</a> does not live in the thread that calls <a href="qthread.html#run">QThread::run</a>().</li>
</ul>
<p><b>Note: </b>A <a href="qobject.html">QObject</a>'s member variables <i>do not</i> automatically become its children. The parent-child relationship must be set by either passing a pointer to the child's <a href="qobject.html#QObject">constructor</a>, or by calling <a href="qobject.html#setParent">setParent</a>(). Without this step, the object's member variables will remain in the old thread when <a href="qobject.html#moveToThread">moveToThread</a>() is called.</p><a name="no-copy-constructor"></a><a name="no-copy-constructor-or-assignment-operator"></a>
<h3 id="no-copy-constructor-or-assignment-operator">No Copy Constructor or Assignment Operator</h3>
<p><a href="qobject.html">QObject</a> has neither a copy constructor nor an assignment operator. This is by design. Actually, they are declared, but in a <code>private</code> section with the macro <a href="qobject.html#Q_DISABLE_COPY">Q_DISABLE_COPY</a>(). In fact, all Qt classes derived from <a href="qobject.html">QObject</a> (direct or indirect) use this macro to declare their copy constructor and assignment operator to be private. The reasoning is found in the discussion on <a href="object.html#identity-vs-value">Identity vs Value</a> on the Qt <a href="object.html">Object Model</a> page.</p>
<p>The main consequence is that you should use pointers to <a href="qobject.html">QObject</a> (or to your <a href="qobject.html">QObject</a> subclass) where you might otherwise be tempted to use your <a href="qobject.html">QObject</a> subclass as a value. For example, without a copy constructor, you can't use a subclass of <a href="qobject.html">QObject</a> as the value to be stored in one of the container classes. You must store pointers.</p>
<a name="auto-connection"></a>
<h3 id="auto-connection">Auto-Connection</h3>
<p>Qt's meta-object system provides a mechanism to automatically connect signals and slots between <a href="qobject.html">QObject</a> subclasses and their children. As long as objects are defined with suitable object names, and slots follow a simple naming convention, this connection can be performed at run-time by the <a href="qmetaobject.html#connectSlotsByName">QMetaObject::connectSlotsByName</a>() function.</p>
<p>uic generates code that invokes this function to enable auto-connection to be performed between widgets on forms created with <i>Qt Designer</i>. More information about using auto-connection with <i>Qt Designer</i> is given in the Using a Designer UI File in Your Application section of the <i>Qt Designer</i> manual.</p>
<a name="dynamic-properties"></a>
<h3 id="dynamic-properties">Dynamic Properties</h3>
<p>From Qt 4.2, dynamic properties can be added to and removed from <a href="qobject.html">QObject</a> instances at run-time. Dynamic properties do not need to be declared at compile-time, yet they provide the same advantages as static properties and are manipulated using the same API - using <a href="qobject.html#property">property</a>() to read them and <a href="qobject.html#setProperty">setProperty</a>() to write them.</p>
<p>From Qt 4.3, dynamic properties are supported by Qt Designer, and both standard Qt widgets and user-created forms can be given dynamic properties.</p>
<a name="internationalization-i18n"></a>
<h3 id="internationalization-i18n">Internationalization (I18n)</h3>
<p>All <a href="qobject.html">QObject</a> subclasses support Qt's translation features, making it possible to translate an application's user interface into different languages.</p>
<p>To make user-visible text translatable, it must be wrapped in calls to the <a href="qobject.html#tr">tr</a>() function. This is explained in detail in the Writing Source Code for Translation document.</p>
</div>
<p><b>See also </b><a href="qmetaobject.html">QMetaObject</a>, <a href="qpointer.html">QPointer</a>, <a href="qobjectcleanuphandler.html">QObjectCleanupHandler</a>, <a href="qobject.html#Q_DISABLE_COPY">Q_DISABLE_COPY</a>(), and <a href="objecttrees.html">Object Trees &amp; Ownership</a>.</p>
<!-- @@@QObject -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$objectName-prop$$$objectName$$$setObjectNameconstQString&$$$objectNameChangedconstQString& -->
<h3 class="fn" id="objectName-prop"><a name="objectName-prop"></a><span class="name">objectName</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the name of this object</p>
<p>You can find an object by name (and type) using <a href="qobject.html#findChild">findChild</a>(). You can find a set of objects with <a href="qobject.html#findChildren">findChildren</a>().</p>
<pre class="cpp">

  <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;MyClass::setPrecision(): (%s) invalid precision %f&quot;</span><span class="operator">,</span>
         <a href="qtglobal.html#qPrintable">qPrintable</a>(objectName())<span class="operator">,</span> newPrecision);

</pre>
<p>By default, this property contains an empty string.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>objectName</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setObjectName</b></span>(const QString &amp;<i>name</i>)</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qobject.html#objectNameChanged">objectNameChanged</a></b></span>(const QString &amp;<i>objectName</i>)</td><td class="memItemRight bottomAlign">[see note below]</td></tr>
</table></div>
<p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p>
<p><b>See also </b><a href="qobject.html#metaObject">metaObject</a>() and <a href="qmetaobject.html#className">QMetaObject::className</a>().</p>
<!-- @@@objectName -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QObject[overload1]$$$QObjectQObject* -->
<h3 class="fn" id="QObject"><a name="QObject"></a>QObject::<span class="name">QObject</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs an object with parent object <i>parent</i>.</p>
<p>The parent of an object may be viewed as the object's owner. For instance, a <a href="../qtwidgets/qdialog.html">dialog box</a> is the parent of the <b>OK</b> and <b>Cancel</b> buttons it contains.</p>
<p>The destructor of a parent object destroys all child objects.</p>
<p>Setting <i>parent</i> to 0 constructs an object with no parent. If the object is a widget, it will become a top-level window.</p>
<p><b>Note: </b>This function can be invoked via the meta-object system and from QML. See <a href="qobject.html#Q_INVOKABLE">Q_INVOKABLE</a>.</p>
<p><b>See also </b><a href="qobject.html#parent">parent</a>(), <a href="qobject.html#findChild">findChild</a>(), and <a href="qobject.html#findChildren">findChildren</a>().</p>
<!-- @@@QObject -->
<!-- $$$~QObject[overload1]$$$~QObject -->
<h3 class="fn" id="dtor.QObject"><a name="dtor.QObject"></a><code>[virtual] </code>QObject::<span class="name">~QObject</span>()</h3>
<p>Destroys the object, deleting all its child objects.</p>
<p>All signals to and from the object are automatically disconnected, and any pending posted events for the object are removed from the event queue. However, it is often safer to use <a href="qobject.html#deleteLater">deleteLater</a>() rather than deleting a <a href="qobject.html">QObject</a> subclass directly.</p>
<p><b>Warning:</b> All child objects are deleted. If any of these objects are on the stack or global, sooner or later your program will crash. We do not recommend holding pointers to child objects from outside the parent. If you still do, the <a href="qobject.html#destroyed">destroyed</a>() signal gives you an opportunity to detect when an object is destroyed.</p>
<p><b>Warning:</b> Deleting a <a href="qobject.html">QObject</a> while pending events are waiting to be delivered can cause a crash. You must not delete the <a href="qobject.html">QObject</a> directly if it exists in a different thread than the one currently executing. Use <a href="qobject.html#deleteLater">deleteLater</a>() instead, which will cause the event loop to delete the object after all pending events have been delivered to it.</p>
<p><b>See also </b><a href="qobject.html#deleteLater">deleteLater</a>().</p>
<!-- @@@~QObject -->
<!-- $$$blockSignals[overload1]$$$blockSignalsbool -->
<h3 class="fn" id="blockSignals"><a name="blockSignals"></a><span class="type">bool</span> QObject::<span class="name">blockSignals</span>(<span class="type">bool</span> <i>block</i>)</h3>
<p>If <i>block</i> is true, signals emitted by this object are blocked (i.e&#x2e;, emitting a signal will not invoke anything connected to it). If <i>block</i> is false, no such blocking will occur.</p>
<p>The return value is the previous value of <a href="qobject.html#signalsBlocked">signalsBlocked</a>().</p>
<p>Note that the <a href="qobject.html#destroyed">destroyed</a>() signal will be emitted even if the signals for this object have been blocked.</p>
<p>Signals emitted while being blocked are not buffered.</p>
<p><b>See also </b><a href="qobject.html#signalsBlocked">signalsBlocked</a>() and <a href="qsignalblocker.html">QSignalBlocker</a>.</p>
<!-- @@@blockSignals -->
<!-- $$$childEvent[overload1]$$$childEventQChildEvent* -->
<h3 class="fn" id="childEvent"><a name="childEvent"></a><code>[virtual protected] </code><span class="type">void</span> QObject::<span class="name">childEvent</span>(<span class="type"><a href="qchildevent.html">QChildEvent</a></span> *<i>event</i>)</h3>
<p>This event handler can be reimplemented in a subclass to receive child events. The event is passed in the <i>event</i> parameter.</p>
<p><a href="qevent.html#Type-enum">QEvent::ChildAdded</a> and <a href="qevent.html#Type-enum">QEvent::ChildRemoved</a> events are sent to objects when children are added or removed. In both cases you can only rely on the child being a <a href="qobject.html">QObject</a>, or if <a href="qobject.html#isWidgetType">isWidgetType</a>() returns <code>true</code>, a <a href="../qtwidgets/qwidget.html">QWidget</a>. (This is because, in the <a href="qevent.html#Type-enum">ChildAdded</a> case, the child is not yet fully constructed, and in the <a href="qevent.html#Type-enum">ChildRemoved</a> case it might have been destructed already).</p>
<p><a href="qevent.html#Type-enum">QEvent::ChildPolished</a> events are sent to widgets when children are polished, or when polished children are added. If you receive a child polished event, the child's construction is usually completed. However, this is not guaranteed, and multiple polish events may be delivered during the execution of a widget's constructor.</p>
<p>For every child widget, you receive one <a href="qevent.html#Type-enum">ChildAdded</a> event, zero or more <a href="qevent.html#Type-enum">ChildPolished</a> events, and one <a href="qevent.html#Type-enum">ChildRemoved</a> event.</p>
<p>The <a href="qevent.html#Type-enum">ChildPolished</a> event is omitted if a child is removed immediately after it is added. If a child is polished several times during construction and destruction, you may receive several child polished events for the same child, each time with a different virtual table.</p>
<p><b>See also </b><a href="qobject.html#event">event</a>().</p>
<!-- @@@childEvent -->
<!-- $$$children[overload1]$$$children -->
<h3 class="fn" id="children"><a name="children"></a>const <span class="type"><a href="qobject.html#QObjectList-typedef">QObjectList</a></span> &amp;QObject::<span class="name">children</span>() const</h3>
<p>Returns a list of child objects. The <a href="qobject.html#QObjectList-typedef">QObjectList</a> class is defined in the <code>&lt;QObject&gt;</code> header file as the following:</p>
<pre class="cpp">

  <span class="keyword">typedef</span> <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">*</span><span class="operator">&gt;</span> <span class="type"><a href="qobject.html#QObjectList-typedef">QObjectList</a></span>;

</pre>
<p>The first child added is the <a href="qlist.html#first">first</a> object in the list and the last child added is the <a href="qlist.html#last">last</a> object in the list, i.e&#x2e; new children are appended at the end.</p>
<p>Note that the list order changes when <a href="../qtwidgets/qwidget.html">QWidget</a> children are <a href="../qtwidgets/qwidget.html#raise">raised</a> or <a href="../qtwidgets/qwidget.html#lower">lowered</a>. A widget that is raised becomes the last object in the list, and a widget that is lowered becomes the first object in the list.</p>
<p><b>See also </b><a href="qobject.html#findChild">findChild</a>(), <a href="qobject.html#findChildren">findChildren</a>(), <a href="qobject.html#parent">parent</a>(), and <a href="qobject.html#setParent">setParent</a>().</p>
<!-- @@@children -->
<!-- $$$connect[overload1]$$$connectconstQObject*constchar*constQObject*constchar*Qt::ConnectionType -->
<h3 class="fn" id="connect"><a name="connect"></a><code>[static] </code><span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> QObject::<span class="name">connect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, const <span class="type">char</span> *<i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type">char</span> *<i>method</i>, <span class="type"><a href="qt.html#ConnectionType-enum">Qt::ConnectionType</a></span> <i>type</i> = Qt::AutoConnection)</h3>
<p>Creates a connection of the given <i>type</i> from the <i>signal</i> in the <i>sender</i> object to the <i>method</i> in the <i>receiver</i> object. Returns a handle to the connection that can be used to disconnect it later.</p>
<p>You must use the <code>SIGNAL()</code> and <code>SLOT()</code> macros when specifying the <i>signal</i> and the <i>method</i>, for example:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span> <span class="operator">*</span>label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span>;
  <span class="type"><a href="../qtwidgets/qscrollbar.html">QScrollBar</a></span> <span class="operator">*</span>scrollBar <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qscrollbar.html">QScrollBar</a></span>;
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(scrollBar<span class="operator">,</span> SIGNAL(valueChanged(<span class="type">int</span>))<span class="operator">,</span>
                   label<span class="operator">,</span>  SLOT(setNum(<span class="type">int</span>)));

</pre>
<p>This example ensures that the label always displays the current scroll bar value. Note that the signal and slots parameters must not contain any variable names, only the type. E.g&#x2e; the following would not work and return false:</p>
<pre class="cpp">

  <span class="comment">// WRONG</span>
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(scrollBar<span class="operator">,</span> SIGNAL(valueChanged(<span class="type">int</span> value))<span class="operator">,</span>
                   label<span class="operator">,</span> SLOT(setNum(<span class="type">int</span> value)));

</pre>
<p>A signal can also be connected to another signal:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyWidget : <span class="keyword">public</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      MyWidget();

  <span class="keyword">signals</span>:
      <span class="type">void</span> buttonClicked();

  <span class="keyword">private</span>:
      <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>myButton;
  };

  MyWidget<span class="operator">::</span>MyWidget()
  {
      myButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>(<span class="keyword">this</span>);
      connect(myButton<span class="operator">,</span> SIGNAL(clicked())<span class="operator">,</span>
              <span class="keyword">this</span><span class="operator">,</span> SIGNAL(buttonClicked()));
  }

</pre>
<p>In this example, the <code>MyWidget</code> constructor relays a signal from a private member variable, and makes it available under a name that relates to <code>MyWidget</code>.</p>
<p>A signal can be connected to many slots and signals. Many signals can be connected to one slot.</p>
<p>If a signal is connected to several slots, the slots are activated in the same order in which the connections were made, when the signal is emitted.</p>
<p>The function returns a <a href="qmetaobject-connection.html">QMetaObject::Connection</a> that represents a handle to a connection if it successfully connects the signal to the slot. The connection handle will be invalid if it cannot create the connection, for example, if <a href="qobject.html">QObject</a> is unable to verify the existence of either <i>signal</i> or <i>method</i>, or if their signatures aren't compatible. You can check if the handle is valid by casting it to a bool.</p>
<p>By default, a signal is emitted for every connection you make; two signals are emitted for duplicate connections. You can break all of these connections with a single <a href="qobject.html#disconnect">disconnect</a>() call. If you pass the <a href="qt.html#ConnectionType-enum">Qt::UniqueConnection</a> <i>type</i>, the connection will only be made if it is not a duplicate. If there is already a duplicate (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid <a href="qmetaobject-connection.html">QMetaObject::Connection</a>.</p>
<p><b>Note: </b>Qt::UniqueConnections do not work for lambdas, non-member functions and functors; they only apply to connecting to member functions.</p><p>The optional <i>type</i> parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time. If the signal is queued, 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="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect: Cannot queue arguments of type <span class="char">'MyType'</span>
  (Make sure <span class="char">'MyType'</span> is registered <span class="keyword">using</span> <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>()<span class="operator">.</span>)

</pre>
<p>call <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>() to register the data type before you establish the connection.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qobject.html#disconnect">disconnect</a>(), <a href="qobject.html#sender">sender</a>(), <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>(), <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>(), and Differences between String-Based and Functor-Based Connections.</p>
<!-- @@@connect -->
<!-- $$$connect$$$connectconstQObject*constQMetaMethod&constQObject*constQMetaMethod&Qt::ConnectionType -->
<h3 class="fn" id="connect-1"><a name="connect-1"></a><code>[static] </code><span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> QObject::<span class="name">connect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>method</i>, <span class="type"><a href="qt.html#ConnectionType-enum">Qt::ConnectionType</a></span> <i>type</i> = Qt::AutoConnection)</h3>
<p>Creates a connection of the given <i>type</i> from the <i>signal</i> in the <i>sender</i> object to the <i>method</i> in the <i>receiver</i> object. Returns a handle to the connection that can be used to disconnect it later.</p>
<p>The Connection handle will be invalid if it cannot create the connection, for example, the parameters were invalid. You can check if the <a href="qmetaobject-connection.html">QMetaObject::Connection</a> is valid by casting it to a bool.</p>
<p>This function works in the same way as <code>connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)</code> but it uses <a href="qmetamethod.html">QMetaMethod</a> to specify signal and method.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qobject.html#connect">connect</a>(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type).</p>
<!-- @@@connect -->
<!-- $$$connect$$$connectconstQObject*constchar*constchar*Qt::ConnectionType -->
<h3 class="fn" id="connect-2"><a name="connect-2"></a><span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> QObject::<span class="name">connect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, const <span class="type">char</span> *<i>signal</i>, const <span class="type">char</span> *<i>method</i>, <span class="type"><a href="qt.html#ConnectionType-enum">Qt::ConnectionType</a></span> <i>type</i> = Qt::AutoConnection) const</h3>
<p>This function overloads <a href="qobject.html#connect">connect</a>().</p>
<p>Connects <i>signal</i> from the <i>sender</i> object to this object's <i>method</i>.</p>
<p>Equivalent to connect(<i>sender</i>, <i>signal</i>, <code>this</code>, <i>method</i>, <i>type</i>).</p>
<p>Every connection you make emits a signal, so duplicate connections emit two signals. You can break a connection using <a href="qobject.html#disconnect">disconnect</a>().</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qobject.html#disconnect">disconnect</a>().</p>
<!-- @@@connect -->
<!-- $$$connect$$$connectconstQObject*PointerToMemberFunctionconstQObject*PointerToMemberFunctionQt::ConnectionType -->
<h3 class="fn" id="connect-3"><a name="connect-3"></a><code>[static] </code><span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> QObject::<span class="name">connect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, <span class="type">PointerToMemberFunction</span> <i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type">PointerToMemberFunction</span> <i>method</i>, <span class="type"><a href="qt.html#ConnectionType-enum">Qt::ConnectionType</a></span> <i>type</i> = Qt::AutoConnection)</h3>
<p>This function overloads <a href="qobject.html#connect">connect</a>().</p>
<p>Creates a connection of the given <i>type</i> from the <i>signal</i> in the <i>sender</i> object to the <i>method</i> in the <i>receiver</i> object. Returns a handle to the connection that can be used to disconnect it later.</p>
<p>The signal must be a function declared as a signal in the header. The slot function can be any member function that can be connected to the signal. A slot can be connected to a given signal if the signal has at least as many arguments as the slot, and there is an implicit conversion between the types of the corresponding arguments in the signal and the slot.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span> <span class="operator">*</span>label <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span>;
  <span class="type"><a href="../qtwidgets/qlineedit.html">QLineEdit</a></span> <span class="operator">*</span>lineEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qlineedit.html">QLineEdit</a></span>;
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(lineEdit<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="../qtwidgets/qlineedit.html">QLineEdit</a></span><span class="operator">::</span>textChanged<span class="operator">,</span>
                   label<span class="operator">,</span>  <span class="operator">&amp;</span><span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span><span class="operator">::</span>setText);

</pre>
<p>This example ensures that the label always displays the current line edit text.</p>
<p>A signal can be connected to many slots and signals. Many signals can be connected to one slot.</p>
<p>If a signal is connected to several slots, the slots are activated in the same order as the order the connection was made, when the signal is emitted</p>
<p>The function returns an handle to a connection if it successfully connects the signal to the slot. The Connection handle will be invalid if it cannot create the connection, for example, if <a href="qobject.html">QObject</a> is unable to verify the existence of <i>signal</i> (if it was not declared as a signal) You can check if the <a href="qmetaobject-connection.html">QMetaObject::Connection</a> is valid by casting it to a bool.</p>
<p>By default, a signal is emitted for every connection you make; two signals are emitted for duplicate connections. You can break all of these connections with a single <a href="qobject.html#disconnect">disconnect</a>() call. If you pass the <a href="qt.html#ConnectionType-enum">Qt::UniqueConnection</a> <i>type</i>, the connection will only be made if it is not a duplicate. If there is already a duplicate (exact same signal to the exact same slot on the same objects), the connection will fail and connect will return an invalid <a href="qmetaobject-connection.html">QMetaObject::Connection</a>.</p>
<p>The optional <i>type</i> parameter describes the type of connection to establish. In particular, it determines whether a particular signal is delivered to a slot immediately or queued for delivery at a later time. If the signal is queued, 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="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect: Cannot queue arguments of type <span class="char">'MyType'</span>
  (Make sure <span class="char">'MyType'</span> is registered <span class="keyword">using</span> <a href="qmetatype.html#qRegisterMetaType-1">qRegisterMetaType</a>()<span class="operator">.</span>)

</pre>
<p>make sure to declare the argument type with <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a></p>
<p>Overloaded functions can be resolved with help of <a href="qtglobal.html#qOverload">qOverload</a>.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b>Differences between String-Based and Functor-Based Connections.</p>
<!-- @@@connect -->
<!-- $$$connect$$$connectconstQObject*PointerToMemberFunctionFunctor -->
<h3 class="fn" id="connect-4"><a name="connect-4"></a><code>[static] </code><span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> QObject::<span class="name">connect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, <span class="type">PointerToMemberFunction</span> <i>signal</i>, <span class="type">Functor</span> <i>functor</i>)</h3>
<p>This function overloads <a href="qobject.html#connect">connect</a>().</p>
<p>Creates a connection from <i>signal</i> in <i>sender</i> object to <i>functor</i>, and returns a handle to the connection</p>
<p>The signal must be a function declared as a signal in the header. The slot function can be any function or functor that can be connected to the signal. A function can be connected to a given signal if the signal has at least as many argument as the slot. A functor can be connected to a signal if they have exactly the same number of arguments. There must exist implicit conversion between the types of the corresponding arguments in the signal and the slot.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type">void</span> someFunction();
  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>;
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(button<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> someFunction);

</pre>
<p>Lambda expressions can also be used:</p>
<pre class="cpp">

  <span class="type"><a href="qbytearray.html">QByteArray</a></span> page <span class="operator">=</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>;
  <span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span> <span class="operator">*</span>socket <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span>;
  socket<span class="operator">-</span><span class="operator">&gt;</span>connectToHost(<span class="string">&quot;qt-project.org&quot;</span><span class="operator">,</span> <span class="number">80</span>);
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(socket<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span><span class="operator">::</span>connected<span class="operator">,</span> <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span> () {
          socket<span class="operator">-</span><span class="operator">&gt;</span>write(<span class="string">&quot;GET &quot;</span> <span class="operator">+</span> page <span class="operator">+</span> <span class="string">&quot;\r\n&quot;</span>);
      });

</pre>
<p>The connection will automatically disconnect if the sender is destroyed. However, you should take care that any objects used within the functor are still alive when the signal is emitted.</p>
<p>Overloaded functions can be resolved with help of <a href="qtglobal.html#qOverload">qOverload</a>.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<!-- @@@connect -->
<!-- $$$connect$$$connectconstQObject*PointerToMemberFunctionconstQObject*FunctorQt::ConnectionType -->
<h3 class="fn" id="connect-5"><a name="connect-5"></a><code>[static] </code><span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> QObject::<span class="name">connect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, <span class="type">PointerToMemberFunction</span> <i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>context</i>, <span class="type">Functor</span> <i>functor</i>, <span class="type"><a href="qt.html#ConnectionType-enum">Qt::ConnectionType</a></span> <i>type</i> = Qt::AutoConnection)</h3>
<p>This function overloads <a href="qobject.html#connect">connect</a>().</p>
<p>Creates a connection of a given <i>type</i> from <i>signal</i> in <i>sender</i> object to <i>functor</i> to be placed in a specific event loop of <i>context</i>, and returns a handle to the connection.</p>
<p><b>Note: </b>Qt::UniqueConnections do not work for lambdas, non-member functions and functors; they only apply to connecting to member functions.</p><p>The signal must be a function declared as a signal in the header. The slot function can be any function or functor that can be connected to the signal. A function can be connected to a given signal if the signal has at least as many argument as the slot. A functor can be connected to a signal if they have exactly the same number of arguments. There must exist implicit conversion between the types of the corresponding arguments in the signal and the slot.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type">void</span> someFunction();
  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>;
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(button<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span><span class="operator">::</span>clicked<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> someFunction<span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>QueuedConnection);

</pre>
<p>Lambda expressions can also be used:</p>
<pre class="cpp">

  <span class="type"><a href="qbytearray.html">QByteArray</a></span> page <span class="operator">=</span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>;
  <span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span> <span class="operator">*</span>socket <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span>;
  socket<span class="operator">-</span><span class="operator">&gt;</span>connectToHost(<span class="string">&quot;qt-project.org&quot;</span><span class="operator">,</span> <span class="number">80</span>);
  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>connect(socket<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span><span class="operator">::</span>connected<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> <span class="operator">[</span><span class="operator">=</span><span class="operator">]</span> () {
          socket<span class="operator">-</span><span class="operator">&gt;</span>write(<span class="string">&quot;GET &quot;</span> <span class="operator">+</span> page <span class="operator">+</span> <span class="string">&quot;\r\n&quot;</span>);
      }<span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>AutoConnection);

</pre>
<p>The connection will automatically disconnect if the sender or the context is destroyed. However, you should take care that any objects used within the functor are still alive when the signal is emitted.</p>
<p>Overloaded functions can be resolved with help of <a href="qtglobal.html#qOverload">qOverload</a>.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@connect -->
<!-- $$$connectNotify[overload1]$$$connectNotifyconstQMetaMethod& -->
<h3 class="fn" id="connectNotify"><a name="connectNotify"></a><code>[virtual protected] </code><span class="type">void</span> QObject::<span class="name">connectNotify</span>(const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>signal</i>)</h3>
<p>This virtual function is called when something has been connected to <i>signal</i> in this object.</p>
<p>If you want to compare <i>signal</i> with a specific signal, you can use <a href="qmetamethod.html#fromSignal">QMetaMethod::fromSignal</a>() as follows:</p>
<pre class="cpp">

  <span class="keyword">if</span> (signal <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span><span class="operator">::</span>fromSignal(<span class="operator">&amp;</span>MyObject<span class="operator">::</span>valueChanged)) {
      <span class="comment">// signal is valueChanged</span>
  }

</pre>
<p><b>Warning:</b> This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.</p>
<p><b>Warning:</b> This function is called from the thread which performs the connection, which may be a different thread from the thread in which this object lives.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qobject.html#connect">connect</a>() and <a href="qobject.html#disconnectNotify">disconnectNotify</a>().</p>
<!-- @@@connectNotify -->
<!-- $$$customEvent[overload1]$$$customEventQEvent* -->
<h3 class="fn" id="customEvent"><a name="customEvent"></a><code>[virtual protected] </code><span class="type">void</span> QObject::<span class="name">customEvent</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>This event handler can be reimplemented in a subclass to receive custom events. Custom events are user-defined events with a type value at least as large as the <a href="qevent.html#Type-enum">QEvent::User</a> item of the <a href="qevent.html#Type-enum">QEvent::Type</a> enum, and is typically a <a href="qevent.html">QEvent</a> subclass. The event is passed in the <i>event</i> parameter.</p>
<p><b>See also </b><a href="qobject.html#event">event</a>() and <a href="qevent.html">QEvent</a>.</p>
<!-- @@@customEvent -->
<!-- $$$deleteLater[overload1]$$$deleteLater -->
<h3 class="fn" id="deleteLater"><a name="deleteLater"></a><code>[slot] </code><span class="type">void</span> QObject::<span class="name">deleteLater</span>()</h3>
<p>Schedules this object for deletion.</p>
<p>The object will be deleted when control returns to the event loop. If the event loop is not running when this function is called (e.g&#x2e; deleteLater() is called on an object before <a href="qcoreapplication.html#exec">QCoreApplication::exec</a>()), the object will be deleted once the event loop is started. If deleteLater() is called after the main event loop has stopped, the object will not be deleted. Since Qt 4.8, if deleteLater() is called on an object that lives in a thread with no running event loop, the object will be destroyed when the thread finishes.</p>
<p>Note that entering and leaving a new event loop (e.g&#x2e;, by opening a modal dialog) will <i>not</i> perform the deferred deletion; for the object to be deleted, the control must return to the event loop from which deleteLater() was called. This does not apply to objects deleted while a previous, nested event loop was still running: the Qt event loop will delete those objects as soon as the new nested event loop starts.</p>
<p><b>Note:</b> It is safe to call this function more than once; when the first deferred deletion event is delivered, any pending events for the object are removed from the event queue.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qobject.html#destroyed">destroyed</a>() and <a href="qpointer.html">QPointer</a>.</p>
<!-- @@@deleteLater -->
<!-- $$$destroyed[overload1]$$$destroyedQObject* -->
<h3 class="fn" id="destroyed"><a name="destroyed"></a><code>[signal] </code><span class="type">void</span> QObject::<span class="name">destroyed</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>obj</i> = nullptr)</h3>
<p>This signal is emitted immediately before the object <i>obj</i> is destroyed, and can not be blocked.</p>
<p>All the objects's children are destroyed immediately after this signal is emitted.</p>
<p><b>See also </b><a href="qobject.html#deleteLater">deleteLater</a>() and <a href="qpointer.html">QPointer</a>.</p>
<!-- @@@destroyed -->
<!-- $$$disconnect[overload1]$$$disconnectconstQObject*constchar*constQObject*constchar* -->
<h3 class="fn" id="disconnect"><a name="disconnect"></a><code>[static] </code><span class="type">bool</span> QObject::<span class="name">disconnect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, const <span class="type">char</span> *<i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type">char</span> *<i>method</i>)</h3>
<p>Disconnects <i>signal</i> in object <i>sender</i> from <i>method</i> in object <i>receiver</i>. Returns <code>true</code> if the connection is successfully broken; otherwise returns <code>false</code>.</p>
<p>A signal-slot connection is removed when either of the objects involved are destroyed.</p>
<p>disconnect() is typically used in three ways, as the following examples demonstrate.</p>
<ol class="1" type="1"><li>Disconnect everything connected to an object's signals:<pre class="cpp">

  disconnect(myObject<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);

</pre>
<p>equivalent to the non-static overloaded function</p>
<pre class="cpp">

  myObject<span class="operator">-</span><span class="operator">&gt;</span>disconnect();

</pre>
</li>
<li>Disconnect everything connected to a specific signal:<pre class="cpp">

  disconnect(myObject<span class="operator">,</span> SIGNAL(mySignal())<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);

</pre>
<p>equivalent to the non-static overloaded function</p>
<pre class="cpp">

  myObject<span class="operator">-</span><span class="operator">&gt;</span>disconnect(SIGNAL(mySignal()));

</pre>
</li>
<li>Disconnect a specific receiver:<pre class="cpp">

  disconnect(myObject<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> myReceiver<span class="operator">,</span> <span class="number">0</span>);

</pre>
<p>equivalent to the non-static overloaded function</p>
<pre class="cpp">

  myObject<span class="operator">-</span><span class="operator">&gt;</span>disconnect(myReceiver);

</pre>
</li>
</ol>
<p>0 may be used as a wildcard, meaning &quot;any signal&quot;, &quot;any receiving object&quot;, or &quot;any slot in the receiving object&quot;, respectively.</p>
<p>The <i>sender</i> may never be 0. (You cannot disconnect signals from more than one object in a single call.)</p>
<p>If <i>signal</i> is 0, it disconnects <i>receiver</i> and <i>method</i> from any signal. If not, only the specified signal is disconnected.</p>
<p>If <i>receiver</i> is 0, it disconnects anything connected to <i>signal</i>. If not, slots in objects other than <i>receiver</i> are not disconnected.</p>
<p>If <i>method</i> is 0, it disconnects anything that is connected to <i>receiver</i>. If not, only slots named <i>method</i> will be disconnected, and all other slots are left alone. The <i>method</i> must be 0 if <i>receiver</i> is left out, so you cannot disconnect a specifically-named slot on all objects.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qobject.html#connect">connect</a>().</p>
<!-- @@@disconnect -->
<!-- $$$disconnect$$$disconnectconstQObject*constQMetaMethod&constQObject*constQMetaMethod& -->
<h3 class="fn" id="disconnect-1"><a name="disconnect-1"></a><code>[static] </code><span class="type">bool</span> QObject::<span class="name">disconnect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>method</i>)</h3>
<p>Disconnects <i>signal</i> in object <i>sender</i> from <i>method</i> in object <i>receiver</i>. Returns <code>true</code> if the connection is successfully broken; otherwise returns <code>false</code>.</p>
<p>This function provides the same possibilities like <code>disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)</code> but uses <a href="qmetamethod.html">QMetaMethod</a> to represent the signal and the method to be disconnected.</p>
<p>Additionally this function returnsfalse and no signals and slots disconnected if:</p>
<ol class="1" type="1"><li><i>signal</i> is not a member of sender class or one of its parent classes.</li>
<li><i>method</i> is not a member of receiver class or one of its parent classes.</li>
<li><i>signal</i> instance represents not a signal.</li>
</ol>
<p>QMetaMethod() may be used as wildcard in the meaning &quot;any signal&quot; or &quot;any slot in receiving object&quot;. In the same way 0 can be used for <i>receiver</i> in the meaning &quot;any receiving object&quot;. In this case method should also be QMetaMethod(). <i>sender</i> parameter should be never 0.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qobject.html#disconnect">disconnect</a>(const QObject *sender, const char *signal, const QObject *receiver, const char *method).</p>
<!-- @@@disconnect -->
<!-- $$$disconnect$$$disconnectconstchar*constQObject*constchar* -->
<h3 class="fn" id="disconnect-2"><a name="disconnect-2"></a><span class="type">bool</span> QObject::<span class="name">disconnect</span>(const <span class="type">char</span> *<i>signal</i> = nullptr, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i> = nullptr, const <span class="type">char</span> *<i>method</i> = nullptr) const</h3>
<p>This function overloads <a href="qobject.html#disconnect">disconnect</a>().</p>
<p>Disconnects <i>signal</i> from <i>method</i> of <i>receiver</i>.</p>
<p>A signal-slot connection is removed when either of the objects involved are destroyed.</p>
<p><b>Note:</b> This function is thread-safe.</p>
<!-- @@@disconnect -->
<!-- $$$disconnect$$$disconnectconstQObject*constchar* -->
<h3 class="fn" id="disconnect-3"><a name="disconnect-3"></a><span class="type">bool</span> QObject::<span class="name">disconnect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, const <span class="type">char</span> *<i>method</i> = nullptr) const</h3>
<p>This function overloads <a href="qobject.html#disconnect">disconnect</a>().</p>
<p>Disconnects all signals in this object from <i>receiver</i>'s <i>method</i>.</p>
<p>A signal-slot connection is removed when either of the objects involved are destroyed.</p>
<!-- @@@disconnect -->
<!-- $$$disconnect$$$disconnectconstQMetaObject::Connection& -->
<h3 class="fn" id="disconnect-4"><a name="disconnect-4"></a><code>[static] </code><span class="type">bool</span> QObject::<span class="name">disconnect</span>(const <span class="type"><a href="qmetaobject-connection.html">QMetaObject::Connection</a></span> &amp;<i>connection</i>)</h3>
<p>Disconnect a connection.</p>
<p>If the <i>connection</i> is invalid or has already been disconnected, do nothing and return false.</p>
<p><b>See also </b><a href="qobject.html#connect">connect</a>().</p>
<!-- @@@disconnect -->
<!-- $$$disconnect$$$disconnectconstQObject*PointerToMemberFunctionconstQObject*PointerToMemberFunction -->
<h3 class="fn" id="disconnect-5"><a name="disconnect-5"></a><code>[static] </code><span class="type">bool</span> QObject::<span class="name">disconnect</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>sender</i>, <span class="type">PointerToMemberFunction</span> <i>signal</i>, const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>receiver</i>, <span class="type">PointerToMemberFunction</span> <i>method</i>)</h3>
<p>This function overloads diconnect().</p>
<p>Disconnects <i>signal</i> in object <i>sender</i> from <i>method</i> in object <i>receiver</i>. Returns <code>true</code> if the connection is successfully broken; otherwise returns <code>false</code>.</p>
<p>A signal-slot connection is removed when either of the objects involved are destroyed.</p>
<p><a href="qobject.html#disconnect">disconnect</a>() is typically used in three ways, as the following examples demonstrate.</p>
<ol class="1" type="1"><li>Disconnect everything connected to an object's signals:<pre class="cpp">

  disconnect(myObject<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);

</pre>
</li>
<li>Disconnect everything connected to a specific signal:<pre class="cpp">

  disconnect(myObject<span class="operator">,</span> <span class="operator">&amp;</span>MyObject<span class="operator">::</span>mySignal()<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>);

</pre>
</li>
<li>Disconnect a specific receiver:<pre class="cpp">

  disconnect(myObject<span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> myReceiver<span class="operator">,</span> <span class="number">0</span>);

</pre>
</li>
<li>Disconnect a connection from one specific signal to a specific slot:<pre class="cpp">

  <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>disconnect(lineEdit<span class="operator">,</span> <span class="operator">&amp;</span><span class="type"><a href="../qtwidgets/qlineedit.html">QLineEdit</a></span><span class="operator">::</span>textChanged<span class="operator">,</span>
                   label<span class="operator">,</span>  <span class="operator">&amp;</span><span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span><span class="operator">::</span>setText);

</pre>
</li>
</ol>
<p>0 may be used as a wildcard, meaning &quot;any signal&quot;, &quot;any receiving object&quot;, or &quot;any slot in the receiving object&quot;, respectively.</p>
<p>The <i>sender</i> may never be 0. (You cannot disconnect signals from more than one object in a single call.)</p>
<p>If <i>signal</i> is 0, it disconnects <i>receiver</i> and <i>method</i> from any signal. If not, only the specified signal is disconnected.</p>
<p>If <i>receiver</i> is 0, it disconnects anything connected to <i>signal</i>. If not, slots in objects other than <i>receiver</i> are not disconnected.</p>
<p>If <i>method</i> is 0, it disconnects anything that is connected to <i>receiver</i>. If not, only slots named <i>method</i> will be disconnected, and all other slots are left alone. The <i>method</i> must be 0 if <i>receiver</i> is left out, so you cannot disconnect a specifically-named slot on all objects.</p>
<p><b>Note: </b>It is not possible to use this overload to diconnect signals connected to functors or lambda expressions. That is because it is not possible to compare them. Instead, use the overload that takes a <a href="qmetaobject-connection.html">QMetaObject::Connection</a></p><p><b>Note:</b> This function is thread-safe.</p>
<p><b>See also </b><a href="qobject.html#connect">connect</a>().</p>
<!-- @@@disconnect -->
<!-- $$$disconnectNotify[overload1]$$$disconnectNotifyconstQMetaMethod& -->
<h3 class="fn" id="disconnectNotify"><a name="disconnectNotify"></a><code>[virtual protected] </code><span class="type">void</span> QObject::<span class="name">disconnectNotify</span>(const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>signal</i>)</h3>
<p>This virtual function is called when something has been disconnected from <i>signal</i> in this object.</p>
<p>See <a href="qobject.html#connectNotify">connectNotify</a>() for an example of how to compare <i>signal</i> with a specific signal.</p>
<p>If all signals were disconnected from this object (e.g&#x2e;, the signal argument to <a href="qobject.html#disconnect">disconnect</a>() was 0), disconnectNotify() is only called once, and the <i>signal</i> will be an invalid <a href="qmetamethod.html">QMetaMethod</a> (<a href="qmetamethod.html#isValid">QMetaMethod::isValid</a>() returns <code>false</code>).</p>
<p><b>Warning:</b> This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.</p>
<p><b>Warning:</b> This function is called from the thread which performs the disconnection, which may be a different thread from the thread in which this object lives. This function may also be called with a <a href="qobject.html">QObject</a> internal mutex locked. It is therefore not allowed to re-enter any of any <a href="qobject.html">QObject</a> functions from your reimplementation and if you lock a mutex in your reimplementation, make sure that you don't call <a href="qobject.html">QObject</a> functions with that mutex held in other places or it will result in a deadlock.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qobject.html#disconnect">disconnect</a>() and <a href="qobject.html#connectNotify">connectNotify</a>().</p>
<!-- @@@disconnectNotify -->
<!-- $$$dumpObjectInfo[overload1]$$$dumpObjectInfo -->
<h3 class="fn" id="dumpObjectInfo"><a name="dumpObjectInfo"></a><span class="type">void</span> QObject::<span class="name">dumpObjectInfo</span>() const</h3>
<p>Dumps information about signal connections, etc. for this object to the debug output.</p>
<p><b>Note: </b>before Qt 5.9, this function was not const.</p><p><b>See also </b><a href="qobject.html#dumpObjectTree">dumpObjectTree</a>().</p>
<!-- @@@dumpObjectInfo -->
<!-- $$$dumpObjectTree[overload1]$$$dumpObjectTree -->
<h3 class="fn" id="dumpObjectTree"><a name="dumpObjectTree"></a><span class="type">void</span> QObject::<span class="name">dumpObjectTree</span>() const</h3>
<p>Dumps a tree of children to the debug output.</p>
<p><b>Note: </b>before Qt 5.9, this function was not const.</p><p><b>See also </b><a href="qobject.html#dumpObjectInfo">dumpObjectInfo</a>().</p>
<!-- @@@dumpObjectTree -->
<!-- $$$dynamicPropertyNames[overload1]$$$dynamicPropertyNames -->
<h3 class="fn" id="dynamicPropertyNames"><a name="dynamicPropertyNames"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qbytearray.html">QByteArray</a></span>&gt; QObject::<span class="name">dynamicPropertyNames</span>() const</h3>
<p>Returns the names of all properties that were dynamically added to the object using <a href="qobject.html#setProperty">setProperty</a>().</p>
<p>This function was introduced in  Qt 4.2.</p>
<!-- @@@dynamicPropertyNames -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn" id="event"><a name="event"></a><code>[virtual] </code><span class="type">bool</span> QObject::<span class="name">event</span>(<span class="type"><a href="qevent.html">QEvent</a></span> *<i>e</i>)</h3>
<p>This virtual function receives events to an object and should return true if the event <i>e</i> was recognized and processed.</p>
<p>The event() function can be reimplemented to customize the behavior of an object.</p>
<p>Make sure you call the parent event class implementation for all the events you did not handle.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyClass : <span class="keyword">public</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      MyClass(<span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);
      <span class="operator">~</span>MyClass();

      bool event(<span class="type"><a href="qevent.html">QEvent</a></span><span class="operator">*</span> ev) override
      {
          <span class="keyword">if</span> (ev<span class="operator">-</span><span class="operator">&gt;</span>type() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qevent.html">QEvent</a></span><span class="operator">::</span>PolishRequest) {
              <span class="comment">// overwrite handling of PolishRequest if any</span>
              doThings();
              <span class="keyword">return</span> <span class="keyword">true</span>;
          } <span class="keyword">else</span>  <span class="keyword">if</span> (ev<span class="operator">-</span><span class="operator">&gt;</span>type() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qevent.html">QEvent</a></span><span class="operator">::</span>Show) {
              <span class="comment">// complement handling of Show if any</span>
              doThings2();
              <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span><span class="operator">::</span>event(ev);
              <span class="keyword">return</span> <span class="keyword">true</span>;
          }
          <span class="comment">// Make sure the rest of events are handled</span>
          <span class="keyword">return</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span><span class="operator">::</span>event(ev);
      }
  };

</pre>
<p><b>See also </b><a href="qobject.html#installEventFilter">installEventFilter</a>(), <a href="qobject.html#timerEvent">timerEvent</a>(), <a href="qcoreapplication.html#sendEvent">QCoreApplication::sendEvent</a>(), and <a href="qcoreapplication.html#postEvent">QCoreApplication::postEvent</a>().</p>
<!-- @@@event -->
<!-- $$$eventFilter[overload1]$$$eventFilterQObject*QEvent* -->
<h3 class="fn" id="eventFilter"><a name="eventFilter"></a><code>[virtual] </code><span class="type">bool</span> QObject::<span class="name">eventFilter</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>watched</i>, <span class="type"><a href="qevent.html">QEvent</a></span> *<i>event</i>)</h3>
<p>Filters events if this object has been installed as an event filter for the <i>watched</i> object.</p>
<p>In your reimplementation of this function, if you want to filter the <i>event</i> out, i.e&#x2e; stop it being handled further, return true; otherwise return false.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MainWindow : <span class="keyword">public</span> <span class="type"><a href="../qtwidgets/qmainwindow.html">QMainWindow</a></span>
  {
  <span class="keyword">public</span>:
      MainWindow();

  <span class="keyword">protected</span>:
      bool eventFilter(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>obj<span class="operator">,</span> <span class="type"><a href="qevent.html">QEvent</a></span> <span class="operator">*</span>ev) override;

  <span class="keyword">private</span>:
      <span class="type"><a href="../qtwidgets/qtextedit.html">QTextEdit</a></span> <span class="operator">*</span>textEdit;
  };

  MainWindow<span class="operator">::</span>MainWindow()
  {
      textEdit <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qtextedit.html">QTextEdit</a></span>;
      setCentralWidget(textEdit);

      textEdit<span class="operator">-</span><span class="operator">&gt;</span>installEventFilter(<span class="keyword">this</span>);
  }

  bool MainWindow<span class="operator">::</span>eventFilter(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>obj<span class="operator">,</span> <span class="type"><a href="qevent.html">QEvent</a></span> <span class="operator">*</span>event)
  {
      <span class="keyword">if</span> (obj <span class="operator">=</span><span class="operator">=</span> textEdit) {
          <span class="keyword">if</span> (event<span class="operator">-</span><span class="operator">&gt;</span>type() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qevent.html">QEvent</a></span><span class="operator">::</span>KeyPress) {
              <span class="type"><a href="../qtgui/qkeyevent.html">QKeyEvent</a></span> <span class="operator">*</span>keyEvent <span class="operator">=</span> <span class="keyword">static_cast</span><span class="operator">&lt;</span><span class="type"><a href="../qtgui/qkeyevent.html">QKeyEvent</a></span><span class="operator">*</span><span class="operator">&gt;</span>(event);
              <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Ate key press&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> keyEvent<span class="operator">-</span><span class="operator">&gt;</span>key();
              <span class="keyword">return</span> <span class="keyword">true</span>;
          } <span class="keyword">else</span> {
              <span class="keyword">return</span> <span class="keyword">false</span>;
          }
      } <span class="keyword">else</span> {
          <span class="comment">// pass the event on to the parent class</span>
          <span class="keyword">return</span> <span class="type"><a href="../qtwidgets/qmainwindow.html">QMainWindow</a></span><span class="operator">::</span>eventFilter(obj<span class="operator">,</span> event);
      }
  }

</pre>
<p>Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.</p>
<p>Some events, such as <a href="qevent.html#Type-enum">QEvent::ShortcutOverride</a> must be explicitly accepted (by calling <a href="qevent.html#accept">accept()</a> on them) in order to prevent propagation.</p>
<p><b>Warning:</b> If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.</p>
<p><b>See also </b><a href="qobject.html#installEventFilter">installEventFilter</a>().</p>
<!-- @@@eventFilter -->
<!-- $$$findChild[overload1]$$$findChildconstQString&Qt::FindChildOptions -->
<h3 class="fn" id="findChild"><a name="findChild"></a><span class="type">T</span> QObject::<span class="name">findChild</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>name</i> = QString(), <span class="type"><a href="qt.html#FindChildOption-enum">Qt::FindChildOptions</a></span> <i>options</i> = Qt::FindChildrenRecursively) const</h3>
<p>Returns the child of this object that can be cast into type T and that is called <i>name</i>, or 0 if there is no such object. Omitting the <i>name</i> argument causes all object names to be matched. The search is performed recursively, unless <i>options</i> specifies the option FindDirectChildrenOnly.</p>
<p>If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, <a href="qobject.html#findChildren">findChildren</a>() should be used.</p>
<p>This example returns a child <code>QPushButton</code> of <code>parentWidget</code> named <code>&quot;button1&quot;</code>, even if the button isn't a direct child of the parent:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> parentWidget<span class="operator">-</span><span class="operator">&gt;</span>findChild<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(<span class="string">&quot;button1&quot;</span>);

</pre>
<p>This example returns a <code>QListWidget</code> child of <code>parentWidget</code>:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qlistwidget.html">QListWidget</a></span> <span class="operator">*</span>list <span class="operator">=</span> parentWidget<span class="operator">-</span><span class="operator">&gt;</span>findChild<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qlistwidget.html">QListWidget</a></span> <span class="operator">*</span><span class="operator">&gt;</span>();

</pre>
<p>This example returns a child <code>QPushButton</code> of <code>parentWidget</code> (its direct parent) named <code>&quot;button1&quot;</code>:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> parentWidget<span class="operator">-</span><span class="operator">&gt;</span>findChild<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(<span class="string">&quot;button1&quot;</span><span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>FindDirectChildrenOnly);

</pre>
<p>This example returns a <code>QListWidget</code> child of <code>parentWidget</code>, its direct parent:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qlistwidget.html">QListWidget</a></span> <span class="operator">*</span>list <span class="operator">=</span> parentWidget<span class="operator">-</span><span class="operator">&gt;</span>findChild<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qlistwidget.html">QListWidget</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(<span class="type"><a href="qstring.html">QString</a></span>()<span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>FindDirectChildrenOnly);

</pre>
<p><b>See also </b><a href="qobject.html#findChildren">findChildren</a>().</p>
<!-- @@@findChild -->
<!-- $$$findChildren[overload1]$$$findChildrenconstQString&Qt::FindChildOptions -->
<h3 class="fn" id="findChildren"><a name="findChildren"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">T</span>&gt; QObject::<span class="name">findChildren</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>name</i> = QString(), <span class="type"><a href="qt.html#FindChildOption-enum">Qt::FindChildOptions</a></span> <i>options</i> = Qt::FindChildrenRecursively) const</h3>
<p>Returns all children of this object with the given <i>name</i> that can be cast to type T, or an empty list if there are no such objects. Omitting the <i>name</i> argument causes all object names to be matched. The search is performed recursively, unless <i>options</i> specifies the option FindDirectChildrenOnly.</p>
<p>The following example shows how to find a list of child <code>QWidget</code>s of the specified <code>parentWidget</code> named <code>widgetname</code>:</p>
<pre class="cpp">

  <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span><span class="operator">&gt;</span> widgets <span class="operator">=</span> parentWidget<span class="operator">.</span>findChildren<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(<span class="string">&quot;widgetname&quot;</span>);

</pre>
<p>This example returns all <code>QPushButton</code>s that are children of <code>parentWidget</code>:</p>
<pre class="cpp">

  <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span> allPButtons <span class="operator">=</span> parentWidget<span class="operator">.</span>findChildren<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span>();

</pre>
<p>This example returns all <code>QPushButton</code>s that are immediate children of <code>parentWidget</code>:</p>
<pre class="cpp">

  <span class="type"><a href="qlist.html">QList</a></span><span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span> childButtons <span class="operator">=</span> parentWidget<span class="operator">.</span>findChildren<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(<span class="type"><a href="qstring.html">QString</a></span>()<span class="operator">,</span> <span class="type">Qt</span><span class="operator">::</span>FindDirectChildrenOnly);

</pre>
<p><b>See also </b><a href="qobject.html#findChild">findChild</a>().</p>
<!-- @@@findChildren -->
<!-- $$$findChildren$$$findChildrenconstQRegExp&Qt::FindChildOptions -->
<h3 class="fn" id="findChildren-1"><a name="findChildren-1"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">T</span>&gt; QObject::<span class="name">findChildren</span>(const <span class="type"><a href="qregexp.html">QRegExp</a></span> &amp;<i>regExp</i>, <span class="type"><a href="qt.html#FindChildOption-enum">Qt::FindChildOptions</a></span> <i>options</i> = Qt::FindChildrenRecursively) const</h3>
<p>This function overloads <a href="qobject.html#findChildren">findChildren</a>().</p>
<p>Returns the children of this object that can be cast to type T and that have names matching the regular expression <i>regExp</i>, or an empty list if there are no such objects. The search is performed recursively, unless <i>options</i> specifies the option FindDirectChildrenOnly.</p>
<!-- @@@findChildren -->
<!-- $$$findChildren$$$findChildrenconstQRegularExpression&Qt::FindChildOptions -->
<h3 class="fn" id="findChildren-2"><a name="findChildren-2"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">T</span>&gt; QObject::<span class="name">findChildren</span>(const <span class="type"><a href="qregularexpression.html">QRegularExpression</a></span> &amp;<i>re</i>, <span class="type"><a href="qt.html#FindChildOption-enum">Qt::FindChildOptions</a></span> <i>options</i> = Qt::FindChildrenRecursively) const</h3>
<p>This function overloads <a href="qobject.html#findChildren">findChildren</a>().</p>
<p>Returns the children of this object that can be cast to type T and that have names matching the regular expression <i>re</i>, or an empty list if there are no such objects. The search is performed recursively, unless <i>options</i> specifies the option FindDirectChildrenOnly.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@findChildren -->
<!-- $$$inherits[overload1]$$$inheritsconstchar* -->
<h3 class="fn" id="inherits"><a name="inherits"></a><span class="type">bool</span> QObject::<span class="name">inherits</span>(const <span class="type">char</span> *<i>className</i>) const</h3>
<p>Returns <code>true</code> if this object is an instance of a class that inherits <i>className</i> or a <a href="qobject.html">QObject</a> subclass that inherits <i>className</i>; otherwise returns <code>false</code>.</p>
<p>A class is considered to inherit itself.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qtimer.html">QTimer</a></span> <span class="operator">*</span>timer <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtimer.html">QTimer</a></span>;         <span class="comment">// QTimer inherits QObject</span>
  timer<span class="operator">-</span><span class="operator">&gt;</span>inherits(<span class="string">&quot;QTimer&quot;</span>);          <span class="comment">// returns true</span>
  timer<span class="operator">-</span><span class="operator">&gt;</span>inherits(<span class="string">&quot;QObject&quot;</span>);         <span class="comment">// returns true</span>
  timer<span class="operator">-</span><span class="operator">&gt;</span>inherits(<span class="string">&quot;QAbstractButton&quot;</span>); <span class="comment">// returns false</span>

  <span class="comment">// QVBoxLayout inherits QObject and QLayoutItem</span>
  <span class="type"><a href="../qtwidgets/qvboxlayout.html">QVBoxLayout</a></span> <span class="operator">*</span>layout <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qvboxlayout.html">QVBoxLayout</a></span>;
  layout<span class="operator">-</span><span class="operator">&gt;</span>inherits(<span class="string">&quot;QObject&quot;</span>);        <span class="comment">// returns true</span>
  layout<span class="operator">-</span><span class="operator">&gt;</span>inherits(<span class="string">&quot;QLayoutItem&quot;</span>);    <span class="comment">// returns true (even though QLayoutItem is not a QObject)</span>

</pre>
<p>If you need to determine whether an object is an instance of a particular class for the purpose of casting it, consider using <a href="qobject.html#qobject_cast">qobject_cast</a>&lt;Type *&gt;(object) instead.</p>
<p><b>See also </b><a href="qobject.html#metaObject">metaObject</a>() and <a href="qobject.html#qobject_cast">qobject_cast</a>().</p>
<!-- @@@inherits -->
<!-- $$$installEventFilter[overload1]$$$installEventFilterQObject* -->
<h3 class="fn" id="installEventFilter"><a name="installEventFilter"></a><span class="type">void</span> QObject::<span class="name">installEventFilter</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>filterObj</i>)</h3>
<p>Installs an event filter <i>filterObj</i> on this object. For example:</p>
<pre class="cpp">

  monitoredObj<span class="operator">-</span><span class="operator">&gt;</span>installEventFilter(filterObj);

</pre>
<p>An event filter is an object that receives all events that are sent to this object. The filter can either stop the event or forward it to this object. The event filter <i>filterObj</i> receives events via its <a href="qobject.html#eventFilter">eventFilter</a>() function. The <a href="qobject.html#eventFilter">eventFilter</a>() function must return true if the event should be filtered, (i.e&#x2e; stopped); otherwise it must return false.</p>
<p>If multiple event filters are installed on a single object, the filter that was installed last is activated first.</p>
<p>Here's a <code>KeyPressEater</code> class that eats the key presses of its monitored objects:</p>
<pre class="cpp">

  <span class="keyword">class</span> KeyPressEater : <span class="keyword">public</span> <span class="type"><a href="qobject.html#QObject">QObject</a></span>
  {
      Q_OBJECT
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

  <span class="keyword">protected</span>:
      bool eventFilter(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>obj<span class="operator">,</span> <span class="type"><a href="qevent.html">QEvent</a></span> <span class="operator">*</span>event) override;
  };

  bool KeyPressEater<span class="operator">::</span>eventFilter(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>obj<span class="operator">,</span> <span class="type"><a href="qevent.html">QEvent</a></span> <span class="operator">*</span>event)
  {
      <span class="keyword">if</span> (event<span class="operator">-</span><span class="operator">&gt;</span>type() <span class="operator">=</span><span class="operator">=</span> <span class="type"><a href="qevent.html">QEvent</a></span><span class="operator">::</span>KeyPress) {
          <span class="type"><a href="../qtgui/qkeyevent.html">QKeyEvent</a></span> <span class="operator">*</span>keyEvent <span class="operator">=</span> <span class="keyword">static_cast</span><span class="operator">&lt;</span><span class="type"><a href="../qtgui/qkeyevent.html">QKeyEvent</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(event);
          <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;Ate key press %d&quot;</span><span class="operator">,</span> keyEvent<span class="operator">-</span><span class="operator">&gt;</span>key());
          <span class="keyword">return</span> <span class="keyword">true</span>;
      } <span class="keyword">else</span> {
          <span class="comment">// standard event processing</span>
          <span class="keyword">return</span> <span class="type"><a href="qobject.html#QObject">QObject</a></span><span class="operator">::</span>eventFilter(obj<span class="operator">,</span> event);
      }
  }

</pre>
<p>And here's how to install it on two widgets:</p>
<pre class="cpp">

  KeyPressEater <span class="operator">*</span>keyPressEater <span class="operator">=</span> <span class="keyword">new</span> KeyPressEater(<span class="keyword">this</span>);
  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span> <span class="operator">*</span>pushButton <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>(<span class="keyword">this</span>);
  <span class="type"><a href="../qtwidgets/qlistview.html">QListView</a></span> <span class="operator">*</span>listView <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qlistview.html">QListView</a></span>(<span class="keyword">this</span>);

  pushButton<span class="operator">-</span><span class="operator">&gt;</span>installEventFilter(keyPressEater);
  listView<span class="operator">-</span><span class="operator">&gt;</span>installEventFilter(keyPressEater);

</pre>
<p>The <a href="../qtwidgets/qshortcut.html">QShortcut</a> class, for example, uses this technique to intercept shortcut key presses.</p>
<p><b>Warning:</b> If you delete the receiver object in your <a href="qobject.html#eventFilter">eventFilter</a>() function, be sure to return true. If you return false, Qt sends the event to the deleted object and the program will crash.</p>
<p>Note that the filtering object must be in the same thread as this object. If <i>filterObj</i> is in a different thread, this function does nothing. If either <i>filterObj</i> or this object are moved to a different thread after calling this function, the event filter will not be called until both objects have the same thread affinity again (it is <i>not</i> removed).</p>
<p><b>See also </b><a href="qobject.html#removeEventFilter">removeEventFilter</a>(), <a href="qobject.html#eventFilter">eventFilter</a>(), and <a href="qobject.html#event">event</a>().</p>
<!-- @@@installEventFilter -->
<!-- $$$isSignalConnected[overload1]$$$isSignalConnectedconstQMetaMethod& -->
<h3 class="fn" id="isSignalConnected"><a name="isSignalConnected"></a><code>[protected] </code><span class="type">bool</span> QObject::<span class="name">isSignalConnected</span>(const <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> &amp;<i>signal</i>) const</h3>
<p>Returns <code>true</code> if the <i>signal</i> is connected to at least one receiver, otherwise returns <code>false</code>.</p>
<p><i>signal</i> must be a signal member of this object, otherwise the behaviour is undefined.</p>
<pre class="cpp">

  <span class="keyword">static</span> <span class="keyword">const</span> <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span> valueChangedSignal <span class="operator">=</span> <span class="type"><a href="qmetamethod.html">QMetaMethod</a></span><span class="operator">::</span>fromSignal(<span class="operator">&amp;</span>MyObject<span class="operator">::</span>valueChanged);
  <span class="keyword">if</span> (isSignalConnected(valueChangedSignal)) {
      <span class="type"><a href="qbytearray.html">QByteArray</a></span> data;
      data <span class="operator">=</span> get_the_value();       <span class="comment">// expensive operation</span>
      <span class="keyword">emit</span> valueChanged(data);
  }

</pre>
<p>As the code snippet above illustrates, you can use this function to avoid emitting a signal that nobody listens to.</p>
<p><b>Warning:</b> This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@isSignalConnected -->
<!-- $$$isWidgetType[overload1]$$$isWidgetType -->
<h3 class="fn" id="isWidgetType"><a name="isWidgetType"></a><span class="type">bool</span> QObject::<span class="name">isWidgetType</span>() const</h3>
<p>Returns <code>true</code> if the object is a widget; otherwise returns <code>false</code>.</p>
<p>Calling this function is equivalent to calling <code>inherits(&quot;QWidget&quot;)</code>, except that it is much faster.</p>
<!-- @@@isWidgetType -->
<!-- $$$isWindowType[overload1]$$$isWindowType -->
<h3 class="fn" id="isWindowType"><a name="isWindowType"></a><span class="type">bool</span> QObject::<span class="name">isWindowType</span>() const</h3>
<p>Returns <code>true</code> if the object is a window; otherwise returns <code>false</code>.</p>
<p>Calling this function is equivalent to calling <code>inherits(&quot;QWindow&quot;)</code>, except that it is much faster.</p>
<!-- @@@isWindowType -->
<!-- $$$killTimer[overload1]$$$killTimerint -->
<h3 class="fn" id="killTimer"><a name="killTimer"></a><span class="type">void</span> QObject::<span class="name">killTimer</span>(<span class="type">int</span> <i>id</i>)</h3>
<p>Kills the timer with timer identifier, <i>id</i>.</p>
<p>The timer identifier is returned by <a href="qobject.html#startTimer">startTimer</a>() when a timer event is started.</p>
<p><b>See also </b><a href="qobject.html#timerEvent">timerEvent</a>() and <a href="qobject.html#startTimer">startTimer</a>().</p>
<!-- @@@killTimer -->
<!-- $$$metaObject[overload1]$$$metaObject -->
<h3 class="fn" id="metaObject"><a name="metaObject"></a><code>[virtual] </code>const <span class="type"><a href="qmetaobject.html">QMetaObject</a></span> *QObject::<span class="name">metaObject</span>() const</h3>
<p>Returns a pointer to the meta-object of this object.</p>
<p>A meta-object contains information about a class that inherits <a href="qobject.html">QObject</a>, e.g&#x2e; class name, superclass name, properties, signals and slots. Every <a href="qobject.html">QObject</a> subclass that contains the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro will have a meta-object.</p>
<p>The meta-object information is required by the signal/slot connection mechanism and the property system. The <a href="qobject.html#inherits">inherits</a>() function also makes use of the meta-object.</p>
<p>If you have no pointer to an actual object instance but still want to access the meta-object of a class, you can use <a href="qobject.html#staticMetaObject-var">staticMetaObject</a>.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>obj <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>;
  obj<span class="operator">-</span><span class="operator">&gt;</span>metaObject()<span class="operator">-</span><span class="operator">&gt;</span>className();             <span class="comment">// returns &quot;QPushButton&quot;</span>

  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span><span class="operator">::</span>staticMetaObject<span class="operator">.</span>className();  <span class="comment">// returns &quot;QPushButton&quot;</span>

</pre>
<p><b>See also </b><a href="qobject.html#staticMetaObject-var">staticMetaObject</a>.</p>
<!-- @@@metaObject -->
<!-- $$$moveToThread[overload1]$$$moveToThreadQThread* -->
<h3 class="fn" id="moveToThread"><a name="moveToThread"></a><span class="type">void</span> QObject::<span class="name">moveToThread</span>(<span class="type"><a href="qthread.html">QThread</a></span> *<i>targetThread</i>)</h3>
<p>Changes the thread affinity for this object and its children. The object cannot be moved if it has a parent. Event processing will continue in the <i>targetThread</i>.</p>
<p>To move an object to the main thread, use QApplication::instance() to retrieve a pointer to the current application, and then use QApplication::thread() to retrieve the thread in which the application lives. For example:</p>
<pre class="cpp">

  myObject<span class="operator">-</span><span class="operator">&gt;</span>moveToThread(<span class="type"><a href="../qtwidgets/qapplication.html">QApplication</a></span><span class="operator">::</span>instance()<span class="operator">-</span><span class="operator">&gt;</span>thread());

</pre>
<p>If <i>targetThread</i> is <code>nullptr</code>, all event processing for this object and its children stops, as they are no longer associated with any thread.</p>
<p>Note that all active timers for the object will be reset. The timers are first stopped in the current thread and restarted (with the same interval) in the <i>targetThread</i>. As a result, constantly moving an object between threads can postpone timer events indefinitely.</p>
<p>A <a href="qevent.html#Type-enum">QEvent::ThreadChange</a> event is sent to this object just before the thread affinity is changed. You can handle this event to perform any special processing. Note that any new events that are posted to this object will be handled in the <i>targetThread</i>, provided it is non-null: when it is <code>nullptr</code>, no event processing for this object or its children can happen, as they are no longer associated with any thread.</p>
<p><b>Warning:</b> This function is <i>not</i> thread-safe; the current thread must be same as the current thread affinity. In other words, this function can only &quot;push&quot; an object from the current thread to another thread, it cannot &quot;pull&quot; an object from any arbitrary thread to the current thread. There is one exception to this rule however: objects with no thread affinity can be &quot;pulled&quot; to the current thread.</p>
<p><b>See also </b><a href="qobject.html#thread">thread</a>().</p>
<!-- @@@moveToThread -->
<!-- $$$objectNameChanged -->
<h3 class="fn" id="objectNameChanged"><a name="objectNameChanged"></a><code>[signal] </code><span class="type">void</span> QObject::<span class="name">objectNameChanged</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>objectName</i>)</h3>
<p>This signal is emitted after the object's name has been changed. The new object name is passed as <i>objectName</i>.</p>
<p><b>Note: </b>This is a private signal. It can be used in signal connections but cannot be emitted by the user.</p>
<p><b>Note:</b> Notifier signal for property <a href="qobject.html#objectName-prop">objectName</a>. </p><p><b>See also </b><a href="qobject.html#objectName-prop">QObject::objectName</a>.</p>
<!-- @@@objectNameChanged -->
<!-- $$$parent[overload1]$$$parent -->
<h3 class="fn" id="parent"><a name="parent"></a><span class="type"><a href="qobject.html#QObject">QObject</a></span> *QObject::<span class="name">parent</span>() const</h3>
<p>Returns a pointer to the parent object.</p>
<p><b>See also </b><a href="qobject.html#setParent">setParent</a>() and <a href="qobject.html#children">children</a>().</p>
<!-- @@@parent -->
<!-- $$$property[overload1]$$$propertyconstchar* -->
<h3 class="fn" id="property"><a name="property"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QObject::<span class="name">property</span>(const <span class="type">char</span> *<i>name</i>) const</h3>
<p>Returns the value of the object's <i>name</i> property.</p>
<p>If no such property exists, the returned variant is invalid.</p>
<p>Information about all available properties is provided through the <a href="qobject.html#metaObject">metaObject</a>() and <a href="qobject.html#dynamicPropertyNames">dynamicPropertyNames</a>().</p>
<p><b>See also </b><a href="qobject.html#setProperty">setProperty</a>(), <a href="qvariant.html#isValid">QVariant::isValid</a>(), <a href="qobject.html#metaObject">metaObject</a>(), and <a href="qobject.html#dynamicPropertyNames">dynamicPropertyNames</a>().</p>
<!-- @@@property -->
<!-- $$$receivers[overload1]$$$receiversconstchar* -->
<h3 class="fn" id="receivers"><a name="receivers"></a><code>[protected] </code><span class="type">int</span> QObject::<span class="name">receivers</span>(const <span class="type">char</span> *<i>signal</i>) const</h3>
<p>Returns the number of receivers connected to the <i>signal</i>.</p>
<p>Since both slots and signals can be used as receivers for signals, and the same connections can be made many times, the number of receivers is the same as the number of connections made from this signal.</p>
<p>When calling this function, you can use the <code>SIGNAL()</code> macro to pass a specific signal:</p>
<pre class="cpp">

  <span class="keyword">if</span> (receivers(SIGNAL(valueChanged(<span class="type"><a href="qbytearray.html">QByteArray</a></span>))) <span class="operator">&gt;</span> <span class="number">0</span>) {
      <span class="type"><a href="qbytearray.html">QByteArray</a></span> data;
      get_the_value(<span class="operator">&amp;</span>data);       <span class="comment">// expensive operation</span>
      <span class="keyword">emit</span> valueChanged(data);
  }

</pre>
<p><b>Warning:</b> This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.</p>
<p><b>See also </b><a href="qobject.html#isSignalConnected">isSignalConnected</a>().</p>
<!-- @@@receivers -->
<!-- $$$removeEventFilter[overload1]$$$removeEventFilterQObject* -->
<h3 class="fn" id="removeEventFilter"><a name="removeEventFilter"></a><span class="type">void</span> QObject::<span class="name">removeEventFilter</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>obj</i>)</h3>
<p>Removes an event filter object <i>obj</i> from this object. The request is ignored if such an event filter has not been installed.</p>
<p>All event filters for this object are automatically removed when this object is destroyed.</p>
<p>It is always safe to remove an event filter, even during event filter activation (i.e&#x2e; from the <a href="qobject.html#eventFilter">eventFilter</a>() function).</p>
<p><b>See also </b><a href="qobject.html#installEventFilter">installEventFilter</a>(), <a href="qobject.html#eventFilter">eventFilter</a>(), and <a href="qobject.html#event">event</a>().</p>
<!-- @@@removeEventFilter -->
<!-- $$$sender[overload1]$$$sender -->
<h3 class="fn" id="sender"><a name="sender"></a><code>[protected] </code><span class="type"><a href="qobject.html#QObject">QObject</a></span> *QObject::<span class="name">sender</span>() const</h3>
<p>Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns <code>nullptr</code>. The pointer is valid only during the execution of the slot that calls this function from this object's thread context.</p>
<p>The pointer returned by this function becomes invalid if the sender is destroyed, or if the slot is disconnected from the sender's signal.</p>
<p><b>Warning:</b> This function violates the object-oriented principle of modularity. However, getting access to the sender might be useful when many signals are connected to a single slot.</p>
<p><b>Warning:</b> As mentioned above, the return value of this function is not valid when the slot is called via a <a href="qt.html#ConnectionType-enum">Qt::DirectConnection</a> from a thread different from this object's thread. Do not use this function in this type of scenario.</p>
<p><b>See also </b><a href="qobject.html#senderSignalIndex">senderSignalIndex</a>().</p>
<!-- @@@sender -->
<!-- $$$senderSignalIndex[overload1]$$$senderSignalIndex -->
<h3 class="fn" id="senderSignalIndex"><a name="senderSignalIndex"></a><code>[protected] </code><span class="type">int</span> QObject::<span class="name">senderSignalIndex</span>() const</h3>
<p>Returns the meta-method index of the signal that called the currently executing slot, which is a member of the class returned by <a href="qobject.html#sender">sender</a>(). If called outside of a slot activated by a signal, -1 is returned.</p>
<p>For signals with default parameters, this function will always return the index with all parameters, regardless of which was used with <a href="qobject.html#connect">connect</a>(). For example, the signal <code>destroyed(QObject *obj = 0)</code> will have two different indexes (with and without the parameter), but this function will always return the index with a parameter. This does not apply when overloading signals with different parameters.</p>
<p><b>Warning:</b> This function violates the object-oriented principle of modularity. However, getting access to the signal index might be useful when many signals are connected to a single slot.</p>
<p><b>Warning:</b> The return value of this function is not valid when the slot is called via a <a href="qt.html#ConnectionType-enum">Qt::DirectConnection</a> from a thread different from this object's thread. Do not use this function in this type of scenario.</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qobject.html#sender">sender</a>(), <a href="qmetaobject.html#indexOfSignal">QMetaObject::indexOfSignal</a>(), and <a href="qmetaobject.html#method">QMetaObject::method</a>().</p>
<!-- @@@senderSignalIndex -->
<!-- $$$setParent[overload1]$$$setParentQObject* -->
<h3 class="fn" id="setParent"><a name="setParent"></a><span class="type">void</span> QObject::<span class="name">setParent</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i>)</h3>
<p>Makes the object a child of <i>parent</i>.</p>
<p><b>See also </b><a href="qobject.html#parent">parent</a>() and <a href="qobject.html#children">children</a>().</p>
<!-- @@@setParent -->
<!-- $$$setProperty[overload1]$$$setPropertyconstchar*constQVariant& -->
<h3 class="fn" id="setProperty"><a name="setProperty"></a><span class="type">bool</span> QObject::<span class="name">setProperty</span>(const <span class="type">char</span> *<i>name</i>, const <span class="type"><a href="qvariant.html">QVariant</a></span> &amp;<i>value</i>)</h3>
<p>Sets the value of the object's <i>name</i> property to <i>value</i>.</p>
<p>If the property is defined in the class using <a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a> then true is returned on success and false otherwise. If the property is not defined using <a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a>, and therefore not listed in the meta-object, it is added as a dynamic property and false is returned.</p>
<p>Information about all available properties is provided through the <a href="qobject.html#metaObject">metaObject</a>() and <a href="qobject.html#dynamicPropertyNames">dynamicPropertyNames</a>().</p>
<p>Dynamic properties can be queried again using <a href="qobject.html#property">property</a>() and can be removed by setting the property value to an invalid <a href="qvariant.html">QVariant</a>. Changing the value of a dynamic property causes a <a href="qdynamicpropertychangeevent.html">QDynamicPropertyChangeEvent</a> to be sent to the object.</p>
<p><b>Note:</b> Dynamic properties starting with &quot;_q_&quot; are reserved for internal purposes.</p>
<p><b>See also </b><a href="qobject.html#property">property</a>(), <a href="qobject.html#metaObject">metaObject</a>(), <a href="qobject.html#dynamicPropertyNames">dynamicPropertyNames</a>(), and <a href="qmetaproperty.html#write">QMetaProperty::write</a>().</p>
<!-- @@@setProperty -->
<!-- $$$signalsBlocked[overload1]$$$signalsBlocked -->
<h3 class="fn" id="signalsBlocked"><a name="signalsBlocked"></a><span class="type">bool</span> QObject::<span class="name">signalsBlocked</span>() const</h3>
<p>Returns <code>true</code> if signals are blocked; otherwise returns <code>false</code>.</p>
<p>Signals are not blocked by default.</p>
<p><b>See also </b><a href="qobject.html#blockSignals">blockSignals</a>() and <a href="qsignalblocker.html">QSignalBlocker</a>.</p>
<!-- @@@signalsBlocked -->
<!-- $$$startTimer[overload1]$$$startTimerintQt::TimerType -->
<h3 class="fn" id="startTimer"><a name="startTimer"></a><span class="type">int</span> QObject::<span class="name">startTimer</span>(<span class="type">int</span> <i>interval</i>, <span class="type"><a href="qt.html#TimerType-enum">Qt::TimerType</a></span> <i>timerType</i> = Qt::CoarseTimer)</h3>
<p>Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.</p>
<p>A timer event will occur every <i>interval</i> milliseconds until <a href="qobject.html#killTimer">killTimer</a>() is called. If <i>interval</i> is 0, then the timer event occurs once every time there are no more window system events to process.</p>
<p>The virtual <a href="qobject.html#timerEvent">timerEvent</a>() function is called with the <a href="qtimerevent.html">QTimerEvent</a> event parameter class when a timer event occurs. Reimplement this function to get timer events.</p>
<p>If multiple timers are running, the <a href="qtimerevent.html#timerId">QTimerEvent::timerId</a>() can be used to find out which timer was activated.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyObject : <span class="keyword">public</span> <span class="type"><a href="qobject.html#QObject">QObject</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      MyObject(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

  <span class="keyword">protected</span>:
      <span class="type">void</span> timerEvent(<span class="type"><a href="qtimerevent.html">QTimerEvent</a></span> <span class="operator">*</span>event) override;
  };

  MyObject<span class="operator">::</span>MyObject(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qobject.html#QObject">QObject</a></span>(parent)
  {
      startTimer(<span class="number">50</span>);     <span class="comment">// 50-millisecond timer</span>
      startTimer(<span class="number">1000</span>);   <span class="comment">// 1-second timer</span>
      startTimer(<span class="number">60000</span>);  <span class="comment">// 1-minute timer</span>

      <span class="keyword">using</span> <span class="keyword">namespace</span> std<span class="operator">::</span>chrono;
      startTimer(milliseconds(<span class="number">50</span>));
      startTimer(seconds(<span class="number">1</span>));
      startTimer(minutes(<span class="number">1</span>));

      <span class="comment">// since C++14 we can use std::chrono::duration literals, e.g.:</span>
      startTimer(<span class="number">100ms</span>);
      startTimer(<span class="number">5s</span>);
      startTimer(<span class="number">2min</span>);
      startTimer(<span class="number">1h</span>);
  }

  <span class="type">void</span> MyObject<span class="operator">::</span>timerEvent(<span class="type"><a href="qtimerevent.html">QTimerEvent</a></span> <span class="operator">*</span>event)
  {
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Timer ID:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> event<span class="operator">-</span><span class="operator">&gt;</span>timerId();
  }

</pre>
<p>Note that <a href="qtimer.html">QTimer</a>'s accuracy depends on the underlying operating system and hardware. The <i>timerType</i> argument allows you to customize the accuracy of the timer. See <a href="qt.html#TimerType-enum">Qt::TimerType</a> for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.</p>
<p>The <a href="qtimer.html">QTimer</a> class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a <a href="qbasictimer.html">QBasicTimer</a> class that is more lightweight than <a href="qtimer.html">QTimer</a> and less clumsy than using timer IDs directly.</p>
<p><b>See also </b><a href="qobject.html#timerEvent">timerEvent</a>(), <a href="qobject.html#killTimer">killTimer</a>(), and <a href="qtimer.html#singleShot">QTimer::singleShot</a>().</p>
<!-- @@@startTimer -->
<!-- $$$startTimer$$$startTimerstd::chrono::millisecondsQt::TimerType -->
<h3 class="fn" id="startTimer-1"><a name="startTimer-1"></a><span class="type">int</span> QObject::<span class="name">startTimer</span>(<span class="type">std::chrono::milliseconds</span> <i>time</i>, <span class="type"><a href="qt.html#TimerType-enum">Qt::TimerType</a></span> <i>timerType</i> = Qt::CoarseTimer)</h3>
<p>This is an overloaded function.</p>
<p>Starts a timer and returns a timer identifier, or returns zero if it could not start a timer.</p>
<p>A timer event will occur every <i>time</i> interval until <a href="qobject.html#killTimer">killTimer</a>() is called. If <i>time</i> is equal to <code>std::chrono::duration::zero()</code>, then the timer event occurs once every time there are no more window system events to process.</p>
<p>The virtual <a href="qobject.html#timerEvent">timerEvent</a>() function is called with the <a href="qtimerevent.html">QTimerEvent</a> event parameter class when a timer event occurs. Reimplement this function to get timer events.</p>
<p>If multiple timers are running, the <a href="qtimerevent.html#timerId">QTimerEvent::timerId</a>() can be used to find out which timer was activated.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyObject : <span class="keyword">public</span> <span class="type"><a href="qobject.html#QObject">QObject</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      MyObject(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>parent <span class="operator">=</span> <span class="number">0</span>);

  <span class="keyword">protected</span>:
      <span class="type">void</span> timerEvent(<span class="type"><a href="qtimerevent.html">QTimerEvent</a></span> <span class="operator">*</span>event) override;
  };

  MyObject<span class="operator">::</span>MyObject(<span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>parent)
      : <span class="type"><a href="qobject.html#QObject">QObject</a></span>(parent)
  {
      startTimer(<span class="number">50</span>);     <span class="comment">// 50-millisecond timer</span>
      startTimer(<span class="number">1000</span>);   <span class="comment">// 1-second timer</span>
      startTimer(<span class="number">60000</span>);  <span class="comment">// 1-minute timer</span>

      <span class="keyword">using</span> <span class="keyword">namespace</span> std<span class="operator">::</span>chrono;
      startTimer(milliseconds(<span class="number">50</span>));
      startTimer(seconds(<span class="number">1</span>));
      startTimer(minutes(<span class="number">1</span>));

      <span class="comment">// since C++14 we can use std::chrono::duration literals, e.g.:</span>
      startTimer(<span class="number">100ms</span>);
      startTimer(<span class="number">5s</span>);
      startTimer(<span class="number">2min</span>);
      startTimer(<span class="number">1h</span>);
  }

  <span class="type">void</span> MyObject<span class="operator">::</span>timerEvent(<span class="type"><a href="qtimerevent.html">QTimerEvent</a></span> <span class="operator">*</span>event)
  {
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;Timer ID:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> event<span class="operator">-</span><span class="operator">&gt;</span>timerId();
  }

</pre>
<p>Note that <a href="qtimer.html">QTimer</a>'s accuracy depends on the underlying operating system and hardware. The <i>timerType</i> argument allows you to customize the accuracy of the timer. See <a href="qt.html#TimerType-enum">Qt::TimerType</a> for information on the different timer types. Most platforms support an accuracy of 20 milliseconds; some provide more. If Qt is unable to deliver the requested number of timer events, it will silently discard some.</p>
<p>The <a href="qtimer.html">QTimer</a> class provides a high-level programming interface with single-shot timers and timer signals instead of events. There is also a <a href="qbasictimer.html">QBasicTimer</a> class that is more lightweight than <a href="qtimer.html">QTimer</a> and less clumsy than using timer IDs directly.</p>
<p>This function was introduced in  Qt 5.9.</p>
<p><b>See also </b><a href="qobject.html#timerEvent">timerEvent</a>(), <a href="qobject.html#killTimer">killTimer</a>(), and <a href="qtimer.html#singleShot">QTimer::singleShot</a>().</p>
<!-- @@@startTimer -->
<!-- $$$thread[overload1]$$$thread -->
<h3 class="fn" id="thread"><a name="thread"></a><span class="type"><a href="qthread.html">QThread</a></span> *QObject::<span class="name">thread</span>() const</h3>
<p>Returns the thread in which the object lives.</p>
<p><b>See also </b><a href="qobject.html#moveToThread">moveToThread</a>().</p>
<!-- @@@thread -->
<!-- $$$timerEvent[overload1]$$$timerEventQTimerEvent* -->
<h3 class="fn" id="timerEvent"><a name="timerEvent"></a><code>[virtual protected] </code><span class="type">void</span> QObject::<span class="name">timerEvent</span>(<span class="type"><a href="qtimerevent.html">QTimerEvent</a></span> *<i>event</i>)</h3>
<p>This event handler can be reimplemented in a subclass to receive timer events for the object.</p>
<p><a href="qtimer.html">QTimer</a> provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the <i>event</i> parameter.</p>
<p><b>See also </b><a href="qobject.html#startTimer">startTimer</a>(), <a href="qobject.html#killTimer">killTimer</a>(), and <a href="qobject.html#event">event</a>().</p>
<!-- @@@timerEvent -->
<!-- $$$tr[overload1]$$$trconstchar*constchar*int -->
<h3 class="fn" id="tr"><a name="tr"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QObject::<span class="name">tr</span>(const <span class="type">char</span> *<i>sourceText</i>, const <span class="type">char</span> *<i>disambiguation</i> = Q_OBJECT, <span class="type">int</span> <i>n</i> = Q_OBJECT)</h3>
<p>Returns a translated version of <i>sourceText</i>, optionally based on a <i>disambiguation</i> string and value of <i>n</i> for strings containing plurals; otherwise returns <a href="qstring.html#fromUtf8">QString::fromUtf8</a>(<i>sourceText</i>) if no appropriate translated string is available.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type">void</span> MainWindow<span class="operator">::</span>createActions()
  {
      <span class="type"><a href="../qtwidgets/qmenu.html">QMenu</a></span> <span class="operator">*</span>fileMenu <span class="operator">=</span> menuBar()<span class="operator">-</span><span class="operator">&gt;</span>addMenu(tr(<span class="string">&quot;&amp;File&quot;</span>));
      ...

</pre>
<p>If the same <i>sourceText</i> is used in different roles within the same context, an additional identifying string may be passed in <i>disambiguation</i> (0 by default). In Qt 4.4 and earlier, this was the preferred way to pass comments to translators.</p>
<p>Example:</p>
<pre class="cpp">

  MyWindow<span class="operator">::</span>MyWindow()
  {
      <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span> <span class="operator">*</span>senderLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Name:&quot;</span>));
      <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span> <span class="operator">*</span>recipientLabel <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qlabel.html">QLabel</a></span>(tr(<span class="string">&quot;Name:&quot;</span><span class="operator">,</span> <span class="string">&quot;recipient&quot;</span>));
      ...

</pre>
<p>See Writing Source Code for Translation for a detailed description of Qt's translation mechanisms in general, and the Disambiguation section for information on disambiguation.</p>
<p><b>Warning:</b> This method is reentrant only if all translators are installed <i>before</i> calling this method. Installing or removing translators while performing translations is not supported. Doing so will probably result in crashes or other undesirable behavior.</p>
<p><b>See also </b><a href="qcoreapplication.html#translate">QCoreApplication::translate</a>() and Internationalization with Qt.</p>
<!-- @@@tr -->
</div>
<div class="vars">
<h2>Member Variable Documentation</h2>
<!-- $$$staticMetaObject -->
<h3 class="fn" id="staticMetaObject-var"><a name="staticMetaObject-var"></a>const <span class="type"><a href="qmetaobject.html">QMetaObject</a></span> QObject::<span class="name">staticMetaObject</span></h3>
<p>This variable stores the meta-object for the class.</p>
<p>A meta-object contains information about a class that inherits <a href="qobject.html">QObject</a>, e.g&#x2e; class name, superclass name, properties, signals and slots. Every class that contains the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro will also have a meta-object.</p>
<p>The meta-object information is required by the signal/slot connection mechanism and the property system. The <a href="qobject.html#inherits">inherits</a>() function also makes use of the meta-object.</p>
<p>If you have a pointer to an object, you can use <a href="qobject.html#metaObject">metaObject</a>() to retrieve the meta-object associated with that object.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span><span class="operator">::</span>staticMetaObject<span class="operator">.</span>className();  <span class="comment">// returns &quot;QPushButton&quot;</span>

  <span class="type"><a href="qobject.html#QObject">QObject</a></span> <span class="operator">*</span>obj <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="../qtwidgets/qpushbutton.html">QPushButton</a></span>;
  obj<span class="operator">-</span><span class="operator">&gt;</span>metaObject()<span class="operator">-</span><span class="operator">&gt;</span>className();             <span class="comment">// returns &quot;QPushButton&quot;</span>

</pre>
<p><b>See also </b><a href="qobject.html#metaObject">metaObject</a>().</p>
<!-- @@@staticMetaObject -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$ -->
<div class="fngroup">
<h3 class="fn fngroupitem" id="qobject_cast"><a name="qobject_cast"></a><span class="type">T</span> <span class="name">qobject_cast</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>object</i>)</h3><h3 class="fn fngroupitem" id="qobject_cast-1"><a name="qobject_cast-1"></a><span class="type">T</span> <span class="name">qobject_cast</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>object</i>)</h3></div>
<p>Returns the given <i>object</i> cast to type T if the object is of type T (or of a subclass); otherwise returns 0. If <i>object</i> is 0 then it will also return 0.</p>
<p>The class T must inherit (directly or indirectly) <a href="qobject.html">QObject</a> and be declared with the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro.</p>
<p>A class is considered to inherit itself.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>obj <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtimer.html">QTimer</a></span>;          <span class="comment">// QTimer inherits QObject</span>

  <span class="type"><a href="qtimer.html">QTimer</a></span> <span class="operator">*</span>timer <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type"><a href="qtimer.html">QTimer</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(obj);
  <span class="comment">// timer == (QObject *)obj</span>

  <span class="type"><a href="../qtwidgets/qabstractbutton.html">QAbstractButton</a></span> <span class="operator">*</span>button <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type"><a href="../qtwidgets/qabstractbutton.html">QAbstractButton</a></span> <span class="operator">*</span><span class="operator">&gt;</span>(obj);
  <span class="comment">// button == 0</span>

</pre>
<p>The <a href="qobject.html#qobject_cast">qobject_cast</a>() function behaves similarly to the standard C++ <code>dynamic_cast()</code>, with the advantages that it doesn't require RTTI support and it works across dynamic library boundaries.</p>
<p><a href="qobject.html#qobject_cast">qobject_cast</a>() can also be used in conjunction with interfaces; see the <a href="../qtwidgets/qtwidgets-tools-plugandpaint-app-example.html">Plug &amp; Paint</a> example for details.</p>
<p><b>Warning:</b> If T isn't declared with the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro, this function's return value is undefined.</p>
<p><b>See also </b><a href="qobject.html#inherits">QObject::inherits</a>().</p>
<!-- @@@ -->
<!-- $$$QObjectList -->
<h3 class="fn" id="QObjectList-typedef"><a name="QObjectList-typedef"></a>typedef <span class="name">QObjectList</span></h3>
<p>Synonym for <a href="qlist.html">QList</a>&lt;<a href="qobject.html">QObject</a> *&gt;.</p>
<!-- @@@QObjectList -->
<!-- $$$qFindChildren[overload1]$$$qFindChildrenconstQObject*constQRegExp& -->
<h3 class="fn" id="qFindChildren"><a name="qFindChildren"></a><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type">T</span>&gt; <span class="name">qFindChildren</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>obj</i>, const <span class="type"><a href="qregexp.html">QRegExp</a></span> &amp;<i>regExp</i>)</h3>
<p>This function overloads qFindChildren().</p>
<p>This function is equivalent to <i>obj</i>-&gt;<a href="qobject.html#findChildren">findChildren</a>&lt;T&gt;(<i>regExp</i>).</p>
<p><b>Note: </b>This function was provided as a workaround for MSVC 6 which did not support member template functions. It is advised to use the other form in new code.</p><p><b>See also </b><a href="qobject.html#findChildren">QObject::findChildren</a>().</p>
<!-- @@@qFindChildren -->
<!-- $$$qobject_cast[overload1]$$$qobject_castQObject* -->
<h3 class="fn" id="qobject_cast"><a name="qobject_cast"></a><span class="type">T</span> <span class="name">qobject_cast</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>object</i>)</h3>
<!-- @@@qobject_cast -->
<!-- $$$qobject_cast$$$qobject_castconstQObject* -->
<h3 class="fn" id="qobject_cast-1"><a name="qobject_cast-1"></a><span class="type">T</span> <span class="name">qobject_cast</span>(const <span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>object</i>)</h3>
<!-- @@@qobject_cast -->
</div>
<div class="macros">
<h2>Macro Documentation</h2>
<!-- $$$QT_NO_NARROWING_CONVERSIONS_IN_CONNECT[overload1]$$$QT_NO_NARROWING_CONVERSIONS_IN_CONNECT -->
<h3 class="fn" id="QT_NO_NARROWING_CONVERSIONS_IN_CONNECT"><a name="QT_NO_NARROWING_CONVERSIONS_IN_CONNECT"></a><span class="name">QT_NO_NARROWING_CONVERSIONS_IN_CONNECT</span></h3>
<p>Defining this macro will disable narrowing and floating-point-to-integral conversions between the arguments carried by a signal and the arguments accepted by a slot, when the signal and the slot are connected using the PMF-based syntax.</p>
<p>This function was introduced in  Qt 5.8.</p>
<p><b>See also </b><a href="qobject.html#connect">QObject::connect</a>.</p>
<!-- @@@QT_NO_NARROWING_CONVERSIONS_IN_CONNECT -->
<!-- $$$Q_CLASSINFO[overload1]$$$Q_CLASSINFO -->
<h3 class="fn" id="Q_CLASSINFO"><a name="Q_CLASSINFO"></a><span class="name">Q_CLASSINFO</span>(<i>Name</i>, <i>Value</i>)</h3>
<p>This macro associates extra information to the class, which is available using <a href="qobject.html#metaObject">QObject::metaObject</a>(). Qt makes only limited use of this feature, in the Active Qt, <a href="../qtdbus/qtdbus-index.html">Qt D-Bus</a> and Qt QML.</p>
<p>The extra information takes the form of a <i>Name</i> string and a <i>Value</i> literal string.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyClass : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
      Q_OBJECT
      Q_CLASSINFO(<span class="string">&quot;Author&quot;</span><span class="operator">,</span> <span class="string">&quot;Pierre Gendron&quot;</span>)
      Q_CLASSINFO(<span class="string">&quot;URL&quot;</span><span class="operator">,</span> <span class="string">&quot;http://www.my-organization.qc.ca&quot;</span>)

  <span class="keyword">public</span>:
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  };

</pre>
<p><b>See also </b><a href="qmetaobject.html#classInfo">QMetaObject::classInfo</a>(), QAxFactory, <a href="../qtdbus/usingadaptors.html">Using Qt D-Bus Adaptors</a>, and Extending QML.</p>
<!-- @@@Q_CLASSINFO -->
<!-- $$$Q_DISABLE_COPY[overload1]$$$Q_DISABLE_COPY -->
<h3 class="fn" id="Q_DISABLE_COPY"><a name="Q_DISABLE_COPY"></a><span class="name">Q_DISABLE_COPY</span>(<i>Class</i>)</h3>
<p>Disables the use of copy constructors and assignment operators for the given <i>Class</i>.</p>
<p>Instances of subclasses of <a href="qobject.html">QObject</a> should not be thought of as values that can be copied or assigned, but as unique identities. This means that when you create your own subclass of <a href="qobject.html">QObject</a> (director or indirect), you should <i>not</i> give it a copy constructor or an assignment operator. However, it may not enough to simply omit them from your class, because, if you mistakenly write some code that requires a copy constructor or an assignment operator (it's easy to do), your compiler will thoughtfully create it for you. You must do more.</p>
<p>The curious user will have seen that the Qt classes derived from <a href="qobject.html">QObject</a> typically include this macro in a private section:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyClass : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
  <span class="keyword">private</span>:
      Q_DISABLE_COPY(MyClass)
  };

</pre>
<p>It declares a copy constructor and an assignment operator in the private section, so that if you use them by mistake, the compiler will report an error.</p>
<pre class="cpp">

  <span class="keyword">class</span> MyClass : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
  <span class="keyword">private</span>:
      MyClass(<span class="keyword">const</span> MyClass <span class="operator">&amp;</span>) <span class="operator">=</span> <span class="keyword">delete</span>;
      MyClass <span class="operator">&amp;</span><span class="keyword">operator</span><span class="operator">=</span>(<span class="keyword">const</span> MyClass <span class="operator">&amp;</span>) <span class="operator">=</span> <span class="keyword">delete</span>;
  };

</pre>
<p>But even this might not catch absolutely every case. You might be tempted to do something like this:</p>
<pre class="cpp">

  <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span> w <span class="operator">=</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span>();

</pre>
<p>First of all, don't do that. Most compilers will generate code that uses the copy constructor, so the privacy violation error will be reported, but your C++ compiler is not required to generate code for this statement in a specific way. It could generate code using <i>neither</i> the copy constructor <i>nor</i> the assignment operator we made private. In that case, no error would be reported, but your application would probably crash when you called a member function of <code>w</code>.</p>
<!-- @@@Q_DISABLE_COPY -->
<!-- $$$Q_EMIT[overload1]$$$Q_EMIT -->
<h3 class="fn" id="Q_EMIT"><a name="Q_EMIT"></a><span class="name">Q_EMIT</span></h3>
<p>Use this macro to replace the <code>emit</code> keyword for emitting signals, when you want to use Qt Signals and Slots with a <a href="signalsandslots.html#3rd-party-signals-and-slots">3rd party signal/slot mechanism</a>.</p>
<p>The macro is normally used when <code>no_keywords</code> is specified with the <code>CONFIG</code> variable in the <code>.pro</code> file, but it can be used even when <code>no_keywords</code> is <i>not</i> specified.</p>
<!-- @@@Q_EMIT -->
<!-- $$$Q_ENUM[overload1]$$$Q_ENUM... -->
<h3 class="fn" id="Q_ENUM"><a name="Q_ENUM"></a><span class="name">Q_ENUM</span>(<i> ...</i>)</h3>
<p>This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a class that has the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> or the <a href="qobject.html#Q_GADGET">Q_GADGET</a> macro. For namespaces use <a href="qobject.html#Q_ENUM_NS">Q_ENUM_NS</a>() instead.</p>
<p>For example:</p>
<pre class="cpp">

  <span class="keyword">class</span> MyClass : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      MyClass(<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="operator">~</span>MyClass();

      <span class="keyword">enum</span> Priority { High<span class="operator">,</span> Low<span class="operator">,</span> VeryHigh<span class="operator">,</span> VeryLow };
      Q_ENUM(Priority)
      <span class="type">void</span> setPriority(Priority priority);
      Priority priority() <span class="keyword">const</span>;
  };

</pre>
<p>Enumerations that are declared with Q_ENUM have their <a href="qmetaenum.html">QMetaEnum</a> registered in the enclosing <a href="qmetaobject.html">QMetaObject</a>. You can also use <a href="qmetaenum.html#fromType">QMetaEnum::fromType</a>() to get the <a href="qmetaenum.html">QMetaEnum</a>.</p>
<p>Registered enumerations are automatically registered also to the Qt meta type system, making them known to <a href="qmetatype.html">QMetaType</a> without the need to use <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>(). This will enable useful features; for example, if used in a <a href="qvariant.html">QVariant</a>, you can convert them to strings. Likewise, passing them to <a href="qdebug.html">QDebug</a> will print out their names.</p>
<p>Mind that the enum values are stored as signed <code>int</code> in the meta object system. Registering enumerations with values outside the range of values valid for <code>int</code> will lead to overflows and potentially undefined behavior when accessing them through the meta object system. QML, for example, does access registered enumerations through the meta object system.</p>
<p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="properties.html">Qt's Property System</a>.</p>
<!-- @@@Q_ENUM -->
<!-- $$$Q_ENUM_NS[overload1]$$$Q_ENUM_NS... -->
<h3 class="fn" id="Q_ENUM_NS"><a name="Q_ENUM_NS"></a><span class="name">Q_ENUM_NS</span>(<i> ...</i>)</h3>
<p>This macro registers an enum type with the meta-object system. It must be placed after the enum declaration in a namespace that has the <a href="qobject.html#Q_NAMESPACE">Q_NAMESPACE</a> macro. It is the same as <a href="qobject.html#Q_ENUM">Q_ENUM</a> but in a namespace.</p>
<p>Enumerations that are declared with Q_ENUM_NS have their <a href="qmetaenum.html">QMetaEnum</a> registered in the enclosing <a href="qmetaobject.html">QMetaObject</a>. You can also use <a href="qmetaenum.html#fromType">QMetaEnum::fromType</a>() to get the <a href="qmetaenum.html">QMetaEnum</a>.</p>
<p>Registered enumerations are automatically registered also to the Qt meta type system, making them known to <a href="qmetatype.html">QMetaType</a> without the need to use <a href="qmetatype.html#Q_DECLARE_METATYPE">Q_DECLARE_METATYPE</a>(). This will enable useful features; for example, if used in a <a href="qvariant.html">QVariant</a>, you can convert them to strings. Likewise, passing them to <a href="qdebug.html">QDebug</a> will print out their names.</p>
<p>Mind that the enum values are stored as signed <code>int</code> in the meta object system. Registering enumerations with values outside the range of values valid for <code>int</code> will lead to overflows and potentially undefined behavior when accessing them through the meta object system. QML, for example, does access registered enumerations through the meta object system.</p>
<p>This function was introduced in  Qt 5.8.</p>
<p><b>See also </b><a href="properties.html">Qt's Property System</a>.</p>
<!-- @@@Q_ENUM_NS -->
<!-- $$$Q_FLAG[overload1]$$$Q_FLAG... -->
<h3 class="fn" id="Q_FLAG"><a name="Q_FLAG"></a><span class="name">Q_FLAG</span>(<i> ...</i>)</h3>
<p>This macro registers a single <a href="qflags.html">flags type</a> with the meta-object system. It is typically used in a class definition to declare that values of a given enum can be used as flags and combined using the bitwise OR operator. For namespaces use <a href="qobject.html#Q_FLAG_NS">Q_FLAG_NS</a>() instead.</p>
<p>The macro must be placed after the enum declaration.</p>
<p>For example, in <a href="qlibrary.html">QLibrary</a>, the <a href="qlibrary.html#LoadHint-enum">LoadHints</a> flag is declared in the following way:</p>
<pre class="cpp">

  <span class="keyword">class</span> <span class="type"><a href="qlibrary.html">QLibrary</a></span> : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>

      <span class="keyword">enum</span> LoadHint {
          ResolveAllSymbolsHint <span class="operator">=</span> <span class="number">0x01</span><span class="operator">,</span>
          ExportExternalSymbolsHint <span class="operator">=</span> <span class="number">0x02</span><span class="operator">,</span>
          LoadArchiveMemberHint <span class="operator">=</span> <span class="number">0x04</span>
      };
      Q_DECLARE_FLAGS(LoadHints<span class="operator">,</span> LoadHint)
      Q_FLAG(LoadHints)
      <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
  }

</pre>
<p>The declaration of the flags themselves is performed in the public section of the <a href="qlibrary.html">QLibrary</a> class itself, using the <a href="qflags.html#Q_DECLARE_FLAGS">Q_DECLARE_FLAGS</a>() macro.</p>
<p><b>Note: </b>The Q_FLAG macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use <a href="qobject.html#Q_ENUM">Q_ENUM</a>() in addition to this macro.</p><p>This function was introduced in  Qt 5.5.</p>
<p><b>See also </b><a href="properties.html">Qt's Property System</a>.</p>
<!-- @@@Q_FLAG -->
<!-- $$$Q_FLAG_NS[overload1]$$$Q_FLAG_NS... -->
<h3 class="fn" id="Q_FLAG_NS"><a name="Q_FLAG_NS"></a><span class="name">Q_FLAG_NS</span>(<i> ...</i>)</h3>
<p>This macro registers a single <a href="qflags.html">flags type</a> with the meta-object system. It is used in a namespace that has the <a href="qobject.html#Q_NAMESPACE">Q_NAMESPACE</a> macro, to declare that values of a given enum can be used as flags and combined using the bitwise OR operator. It is the same as <a href="qobject.html#Q_FLAG">Q_FLAG</a> but in a namespace.</p>
<p>The macro must be placed after the enum declaration.</p>
<p><b>Note: </b>The Q_FLAG_NS macro takes care of registering individual flag values with the meta-object system, so it is unnecessary to use <a href="qobject.html#Q_ENUM_NS">Q_ENUM_NS</a>() in addition to this macro.</p><p>This function was introduced in  Qt 5.8.</p>
<p><b>See also </b><a href="properties.html">Qt's Property System</a>.</p>
<!-- @@@Q_FLAG_NS -->
<!-- $$$Q_GADGET[overload1]$$$Q_GADGET -->
<h3 class="fn" id="Q_GADGET"><a name="Q_GADGET"></a><span class="name">Q_GADGET</span></h3>
<p>The Q_GADGET macro is a lighter version of the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro for classes that do not inherit from <a href="qobject.html">QObject</a> but still want to use some of the reflection capabilities offered by <a href="qmetaobject.html">QMetaObject</a>. Just like the <a href="qobject.html#Q_OBJECT">Q_OBJECT</a> macro, it must appear in the private section of a class definition.</p>
<p>Q_GADGETs can have <a href="qobject.html#Q_ENUM">Q_ENUM</a>, <a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a> and <a href="qobject.html#Q_INVOKABLE">Q_INVOKABLE</a>, but they cannot have signals or slots.</p>
<p>Q_GADGET makes a class member, <code>staticMetaObject</code>, available. <code>staticMetaObject</code> is of type <a href="qmetaobject.html">QMetaObject</a> and provides access to the enums declared with Q_ENUMS.</p>
<!-- @@@Q_GADGET -->
<!-- $$$Q_INTERFACES[overload1]$$$Q_INTERFACES... -->
<h3 class="fn" id="Q_INTERFACES"><a name="Q_INTERFACES"></a><span class="name">Q_INTERFACES</span>(<i> ...</i>)</h3>
<p>This macro tells Qt which interfaces the class implements. This is used when implementing plugins.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="keyword">class</span> BasicToolsPlugin : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span><span class="operator">,</span>
                           <span class="keyword">public</span> BrushInterface<span class="operator">,</span>
                           <span class="keyword">public</span> ShapeInterface<span class="operator">,</span>
                           <span class="keyword">public</span> FilterInterface
  {
      Q_OBJECT
      Q_PLUGIN_METADATA(IID <span class="string">&quot;org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface&quot;</span> FILE <span class="string">&quot;basictools.json&quot;</span>)
      Q_INTERFACES(BrushInterface ShapeInterface FilterInterface)

  <span class="keyword">public</span>:
      ...
  };

</pre>
<p>See the <a href="../qtwidgets/qtwidgets-tools-plugandpaint-plugins-basictools-example.html">Plug &amp; Paint Basic Tools</a> example for details.</p>
<p><b>See also </b><a href="qtplugin.html#Q_DECLARE_INTERFACE">Q_DECLARE_INTERFACE</a>(), <a href="qtplugin.html#Q_PLUGIN_METADATA">Q_PLUGIN_METADATA</a>(), and How to Create Qt Plugins.</p>
<!-- @@@Q_INTERFACES -->
<!-- $$$Q_INVOKABLE[overload1]$$$Q_INVOKABLE -->
<h3 class="fn" id="Q_INVOKABLE"><a name="Q_INVOKABLE"></a><span class="name">Q_INVOKABLE</span></h3>
<p>Apply this macro to declarations of member functions to allow them to be invoked via the meta-object system. The macro is written before the return type, as shown in the following example:</p>
<pre class="cpp">

  <span class="keyword">class</span> Window : <span class="keyword">public</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      Window();
      <span class="type">void</span> normalMethod();
      Q_INVOKABLE <span class="type">void</span> invokableMethod();
  };

</pre>
<p>The <code>invokableMethod()</code> function is marked up using Q_INVOKABLE, causing it to be registered with the meta-object system and enabling it to be invoked using <a href="qmetaobject.html#invokeMethod">QMetaObject::invokeMethod</a>(). Since <code>normalMethod()</code> function is not registered in this way, it cannot be invoked using <a href="qmetaobject.html#invokeMethod">QMetaObject::invokeMethod</a>().</p>
<p>If an invokable member function returns a pointer to a <a href="qobject.html">QObject</a> or a subclass of <a href="qobject.html">QObject</a> and it is invoked from QML, special ownership rules apply. See Data Type Conversion Between QML and C++ for more information.</p>
<!-- @@@Q_INVOKABLE -->
<!-- $$$Q_NAMESPACE[overload1]$$$Q_NAMESPACE -->
<h3 class="fn" id="Q_NAMESPACE"><a name="Q_NAMESPACE"></a><span class="name">Q_NAMESPACE</span></h3>
<p>The Q_NAMESPACE macro can be used to add <a href="qmetaobject.html">QMetaObject</a> capabilities to a namespace.</p>
<p>Q_NAMESPACEs can have <a href="qobject.html#Q_CLASSINFO">Q_CLASSINFO</a>, <a href="qobject.html#Q_ENUM_NS">Q_ENUM_NS</a>, <a href="qobject.html#Q_FLAG_NS">Q_FLAG_NS</a>, but they cannot have <a href="qobject.html#Q_ENUM">Q_ENUM</a>, <a href="qobject.html#Q_FLAG">Q_FLAG</a>, <a href="qobject.html#Q_PROPERTY">Q_PROPERTY</a>, <a href="qobject.html#Q_INVOKABLE">Q_INVOKABLE</a>, signals nor slots.</p>
<p>Q_NAMESPACE makes an external variable, <code>staticMetaObject</code>, available. <code>staticMetaObject</code> is of type <a href="qmetaobject.html">QMetaObject</a> and provides access to the enums declared with <a href="qobject.html#Q_ENUM_NS">Q_ENUM_NS</a>/<a href="qobject.html#Q_FLAG_NS">Q_FLAG_NS</a>.</p>
<p>This function was introduced in  Qt 5.8.</p>
<!-- @@@Q_NAMESPACE -->
<!-- $$$Q_OBJECT[overload1]$$$Q_OBJECT -->
<h3 class="fn" id="Q_OBJECT"><a name="Q_OBJECT"></a><span class="name">Q_OBJECT</span></h3>
<p>The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system.</p>
<p>For example:</p>
<pre class="cpp">

  <span class="preprocessor">#include &lt;QObject&gt;</span>

  <span class="keyword">class</span> Counter : <span class="keyword">public</span> <span class="type"><a href="qobject.html">QObject</a></span>
  {
      Q_OBJECT

  <span class="keyword">public</span>:
      Counter() { m_value <span class="operator">=</span> <span class="number">0</span>; }

      <span class="type">int</span> value() <span class="keyword">const</span> { <span class="keyword">return</span> m_value; }

  <span class="keyword">public</span> <span class="keyword">slots</span>:
      <span class="type">void</span> setValue(<span class="type">int</span> value);

  <span class="keyword">signals</span>:
      <span class="type">void</span> valueChanged(<span class="type">int</span> newValue);

  <span class="keyword">private</span>:
      <span class="type">int</span> m_value;
  };

</pre>
<p><b>Note: </b>This macro requires the class to be a subclass of <a href="qobject.html">QObject</a>. Use <a href="qobject.html#Q_GADGET">Q_GADGET</a> instead of Q_OBJECT to enable the meta object system's support for enums in a class that is not a <a href="qobject.html">QObject</a> subclass.</p><p><b>See also </b><a href="metaobjects.html">Meta-Object System</a>, <a href="signalsandslots.html">Signals and Slots</a>, and <a href="properties.html">Qt's Property System</a>.</p>
<!-- @@@Q_OBJECT -->
<!-- $$$Q_PROPERTY[overload1]$$$Q_PROPERTY... -->
<h3 class="fn" id="Q_PROPERTY"><a name="Q_PROPERTY"></a><span class="name">Q_PROPERTY</span>(<i> ...</i>)</h3>
<p>This macro is used for declaring properties in classes that inherit <a href="qobject.html">QObject</a>. Properties behave like class data members, but they have additional features accessible through the <a href="metaobjects.html">Meta-Object System</a>.</p>
<pre class="cpp">

  Q_PROPERTY(type name
             (READ getFunction <span class="operator">[</span>WRITE setFunction<span class="operator">]</span> <span class="operator">|</span>
              MEMBER memberName <span class="operator">[</span>(READ getFunction <span class="operator">|</span> WRITE setFunction)<span class="operator">]</span>)
             <span class="operator">[</span>RESET resetFunction<span class="operator">]</span>
             <span class="operator">[</span>NOTIFY notifySignal<span class="operator">]</span>
             <span class="operator">[</span>REVISION <span class="type">int</span><span class="operator">]</span>
             <span class="operator">[</span>DESIGNABLE bool<span class="operator">]</span>
             <span class="operator">[</span>SCRIPTABLE bool<span class="operator">]</span>
             <span class="operator">[</span>STORED bool<span class="operator">]</span>
             <span class="operator">[</span>USER bool<span class="operator">]</span>
             <span class="operator">[</span>CONSTANT<span class="operator">]</span>
             <span class="operator">[</span>FINAL<span class="operator">]</span>)

</pre>
<p>The property name and type and the <code>READ</code> function are required. The type can be any type supported by <a href="qvariant.html">QVariant</a>, or it can be a user-defined type. The other items are optional, but a <code>WRITE</code> function is common. The attributes default to true except <code>USER</code>, which defaults to false.</p>
<p>For example:</p>
<pre class="cpp">

  Q_PROPERTY(<span class="type"><a href="qstring.html">QString</a></span> title READ title WRITE setTitle USER <span class="keyword">true</span>)

</pre>
<p>For more details about how to use this macro, and a more detailed example of its use, see the discussion on <a href="properties.html">Qt's Property System</a>.</p>
<p><b>See also </b><a href="properties.html">Qt's Property System</a>.</p>
<!-- @@@Q_PROPERTY -->
<!-- $$$Q_REVISION[overload1]$$$Q_REVISION -->
<h3 class="fn" id="Q_REVISION"><a name="Q_REVISION"></a><span class="name">Q_REVISION</span></h3>
<p>Apply this macro to declarations of member functions to tag them with a revision number in the meta-object system. The macro is written before the return type, as shown in the following example:</p>
<pre class="cpp">

  <span class="keyword">class</span> Window : <span class="keyword">public</span> <span class="type"><a href="../qtwidgets/qwidget.html">QWidget</a></span>
  {
      Q_OBJECT
      Q_PROPERTY(<span class="type">int</span> normalProperty READ normalProperty)
      Q_PROPERTY(<span class="type">int</span> newProperty READ newProperty REVISION <span class="number">1</span>)

  <span class="keyword">public</span>:
      Window();
      <span class="type">int</span> normalProperty();
      <span class="type">int</span> newProperty();
  <span class="keyword">public</span> <span class="keyword">slots</span>:
      <span class="type">void</span> normalMethod();
      Q_REVISION(<span class="number">1</span>) <span class="type">void</span> newMethod();
  };

</pre>
<p>This is useful when using the meta-object system to dynamically expose objects to another API, as you can match the version expected by multiple versions of the other API. Consider the following simplified example:</p>
<pre class="cpp">

      Window window;
      <span class="type">int</span> expectedRevision <span class="operator">=</span> <span class="number">0</span>;
      <span class="keyword">const</span> <span class="type"><a href="qmetaobject.html">QMetaObject</a></span> <span class="operator">*</span>windowMetaObject <span class="operator">=</span> window<span class="operator">.</span>metaObject();
      <span class="keyword">for</span> (<span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>; i <span class="operator">&lt;</span> windowMetaObject<span class="operator">-</span><span class="operator">&gt;</span>methodCount(); i<span class="operator">+</span><span class="operator">+</span>)
          <span class="keyword">if</span> (windowMetaObject<span class="operator">-</span><span class="operator">&gt;</span>method(i)<span class="operator">.</span>revision() <span class="operator">&lt;</span><span class="operator">=</span> expectedRevision)
              exposeMethod(windowMetaObject<span class="operator">-</span><span class="operator">&gt;</span>method(i));
      <span class="keyword">for</span> (<span class="type">int</span> i<span class="operator">=</span><span class="number">0</span>; i <span class="operator">&lt;</span> windowMetaObject<span class="operator">-</span><span class="operator">&gt;</span>propertyCount(); i<span class="operator">+</span><span class="operator">+</span>)
          <span class="keyword">if</span> (windowMetaObject<span class="operator">-</span><span class="operator">&gt;</span>property(i)<span class="operator">.</span>revision() <span class="operator">&lt;</span><span class="operator">=</span> expectedRevision)
              exposeProperty(windowMetaObject<span class="operator">-</span><span class="operator">&gt;</span>property(i));

</pre>
<p>Using the same Window class as the previous example, the newProperty and newMethod would only be exposed in this code when the expected version is 1 or greater.</p>
<p>Since all methods are considered to be in revision 0 if untagged, a tag of Q_REVISION(0) is invalid and ignored.</p>
<p>This tag is not used by the meta-object system itself. Currently this is only used by the QtQml module.</p>
<p>For a more generic string tag, see <a href="qmetamethod.html#tag">QMetaMethod::tag</a>()</p>
<p><b>See also </b><a href="qmetamethod.html#revision">QMetaMethod::revision</a>().</p>
<!-- @@@Q_REVISION -->
<!-- $$$Q_SET_OBJECT_NAME[overload1]$$$Q_SET_OBJECT_NAME -->
<h3 class="fn" id="Q_SET_OBJECT_NAME"><a name="Q_SET_OBJECT_NAME"></a><span class="name">Q_SET_OBJECT_NAME</span>(<i>Object</i>)</h3>
<p>This macro assigns <i>Object</i> the objectName &quot;Object&quot;.</p>
<p>It doesn't matter whether <i>Object</i> is a pointer or not, the macro figures that out by itself.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qobject.html#objectName-prop">QObject::objectName</a>().</p>
<!-- @@@Q_SET_OBJECT_NAME -->
<!-- $$$Q_SIGNAL[overload1]$$$Q_SIGNAL -->
<h3 class="fn" id="Q_SIGNAL"><a name="Q_SIGNAL"></a><span class="name">Q_SIGNAL</span></h3>
<p>This is an additional macro that allows you to mark a single function as a signal. It can be quite useful, especially when you use a 3rd-party source code parser which doesn't understand a <code>signals</code> or <code>Q_SIGNALS</code> groups.</p>
<p>Use this macro to replace the <code>signals</code> keyword in class declarations, when you want to use Qt Signals and Slots with a <a href="signalsandslots.html#3rd-party-signals-and-slots">3rd party signal/slot mechanism</a>.</p>
<p>The macro is normally used when <code>no_keywords</code> is specified with the <code>CONFIG</code> variable in the <code>.pro</code> file, but it can be used even when <code>no_keywords</code> is <i>not</i> specified.</p>
<!-- @@@Q_SIGNAL -->
<!-- $$$Q_SIGNALS[overload1]$$$Q_SIGNALS -->
<h3 class="fn" id="Q_SIGNALS"><a name="Q_SIGNALS"></a><span class="name">Q_SIGNALS</span></h3>
<p>Use this macro to replace the <code>signals</code> keyword in class declarations, when you want to use Qt Signals and Slots with a <a href="signalsandslots.html#3rd-party-signals-and-slots">3rd party signal/slot mechanism</a>.</p>
<p>The macro is normally used when <code>no_keywords</code> is specified with the <code>CONFIG</code> variable in the <code>.pro</code> file, but it can be used even when <code>no_keywords</code> is <i>not</i> specified.</p>
<!-- @@@Q_SIGNALS -->
<!-- $$$Q_SLOT[overload1]$$$Q_SLOT -->
<h3 class="fn" id="Q_SLOT"><a name="Q_SLOT"></a><span class="name">Q_SLOT</span></h3>
<p>This is an additional macro that allows you to mark a single function as a slot. It can be quite useful, especially when you use a 3rd-party source code parser which doesn't understand a <code>slots</code> or <code>Q_SLOTS</code> groups.</p>
<p>Use this macro to replace the <code>slots</code> keyword in class declarations, when you want to use Qt Signals and Slots with a <a href="signalsandslots.html#3rd-party-signals-and-slots">3rd party signal/slot mechanism</a>.</p>
<p>The macro is normally used when <code>no_keywords</code> is specified with the <code>CONFIG</code> variable in the <code>.pro</code> file, but it can be used even when <code>no_keywords</code> is <i>not</i> specified.</p>
<!-- @@@Q_SLOT -->
<!-- $$$Q_SLOTS[overload1]$$$Q_SLOTS -->
<h3 class="fn" id="Q_SLOTS"><a name="Q_SLOTS"></a><span class="name">Q_SLOTS</span></h3>
<p>Use this macro to replace the <code>slots</code> keyword in class declarations, when you want to use Qt Signals and Slots with a <a href="signalsandslots.html#3rd-party-signals-and-slots">3rd party signal/slot mechanism</a>.</p>
<p>The macro is normally used when <code>no_keywords</code> is specified with the <code>CONFIG</code> variable in the <code>.pro</code> file, but it can be used even when <code>no_keywords</code> is <i>not</i> specified.</p>
<!-- @@@Q_SLOTS -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   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/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>