[190] | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
| 2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qobject.cpp:105 -->
|
---|
| 3 | <html>
|
---|
| 4 | <head>
|
---|
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
| 6 | <title>QObject Class</title>
|
---|
| 7 | <style type="text/css"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QObject Class Reference</h1>
|
---|
| 33 |
|
---|
| 34 | <p>The QObject class is the base class of all Qt objects.
|
---|
| 35 | <a href="#details">More...</a>
|
---|
| 36 | <p>All the functions in this class are <a href="threads.html#reentrant">reentrant</a> when Qt is built with thread support.</p>
|
---|
| 37 | <p><tt>#include <<a href="qobject-h.html">qobject.h</a>></tt>
|
---|
| 38 | <p>Inherits <a href="qt.html">Qt</a>.
|
---|
| 39 | <p>Inherited by <a href="qaccel.html">QAccel</a>, <a href="qaccessibleobject.html">QAccessibleObject</a>, <a href="qaction.html">QAction</a>, <a href="qapplication.html">QApplication</a>, <a href="qassistantclient.html">QAssistantClient</a>, <a href="qdatapump.html">QDataPump</a>, <a href="qaxobject.html">QAxObject</a>, <a href="qaxscript.html">QAxScript</a>, <a href="qaxscriptmanager.html">QAxScriptManager</a>, <a href="qwidget.html">QWidget</a>, <a href="qcanvas.html">QCanvas</a>, <a href="qstyle.html">QStyle</a>, <a href="qclipboard.html">QClipboard</a>, <a href="qcopchannel.html">QCopChannel</a>, <a href="qdns.html">QDns</a>, <a href="qlayout.html">QLayout</a>, <a href="qdragobject.html">QDragObject</a>, <a href="qeditorfactory.html">QEditorFactory</a>, <a href="qeventloop.html">QEventLoop</a>, <a href="qfileiconprovider.html">QFileIconProvider</a>, <a href="qnetworkprotocol.html">QNetworkProtocol</a>, <a href="qwskeyboardhandler.html">QWSKeyboardHandler</a>, <a href="qnetworkoperation.html">QNetworkOperation</a>, <a href="qnpinstance.html">QNPInstance</a>, <a href="qobjectcleanuphandler.html">QObjectCleanupHandler</a>, <a href="qprocess.html">QProcess</a>, <a href="qserversocket.html">QServerSocket</a>, <a href="qsessionmanager.html">QSessionManager</a>, <a href="qsignal.html">QSignal</a>, <a href="qsignalmapper.html">QSignalMapper</a>, <a href="qsocket.html">QSocket</a>, <a href="qsocketnotifier.html">QSocketNotifier</a>, <a href="qsound.html">QSound</a>, <a href="qsqldatabase.html">QSqlDatabase</a>, <a href="qsqldriver.html">QSqlDriver</a>, <a href="qsqlform.html">QSqlForm</a>, <a href="qstylesheet.html">QStyleSheet</a>, <a href="qtimer.html">QTimer</a>, <a href="qtooltipgroup.html">QToolTipGroup</a>, <a href="qtranslator.html">QTranslator</a>, <a href="qurloperator.html">QUrlOperator</a>, and <a href="qvalidator.html">QValidator</a>.
|
---|
| 40 | <p><a href="qobject-members.html">List of all member functions.</a>
|
---|
| 41 | <h2>Public Members</h2>
|
---|
| 42 | <ul>
|
---|
| 43 | <li class=fn><a href="#QObject"><b>QObject</b></a> ( QObject * parent = 0, const char * name = 0 )</li>
|
---|
| 44 | <li class=fn>virtual <a href="#~QObject"><b>~QObject</b></a> ()</li>
|
---|
| 45 | <li class=fn>virtual const char * <a href="#className"><b>className</b></a> () const</li>
|
---|
| 46 | <li class=fn>virtual QMetaObject * <a href="#metaObject"><b>metaObject</b></a> () const</li>
|
---|
| 47 | <li class=fn>virtual bool <a href="#event"><b>event</b></a> ( QEvent * e )</li>
|
---|
| 48 | <li class=fn>virtual bool <a href="#eventFilter"><b>eventFilter</b></a> ( QObject * watched, QEvent * e )</li>
|
---|
| 49 | <li class=fn>bool <a href="#isA"><b>isA</b></a> ( const char * clname ) const</li>
|
---|
| 50 | <li class=fn>bool <a href="#inherits"><b>inherits</b></a> ( const char * clname ) const</li>
|
---|
| 51 | <li class=fn>const char * <a href="#name"><b>name</b></a> () const</li>
|
---|
| 52 | <li class=fn>const char * <a href="#name-2"><b>name</b></a> ( const char * defaultName ) const</li>
|
---|
| 53 | <li class=fn>virtual void <a href="#setName"><b>setName</b></a> ( const char * name )</li>
|
---|
| 54 | <li class=fn>bool <a href="#isWidgetType"><b>isWidgetType</b></a> () const</li>
|
---|
| 55 | <li class=fn>bool <a href="#highPriority"><b>highPriority</b></a> () const</li>
|
---|
| 56 | <li class=fn>bool <a href="#signalsBlocked"><b>signalsBlocked</b></a> () const</li>
|
---|
| 57 | <li class=fn>void <a href="#blockSignals"><b>blockSignals</b></a> ( bool block )</li>
|
---|
| 58 | <li class=fn>int <a href="#startTimer"><b>startTimer</b></a> ( int interval )</li>
|
---|
| 59 | <li class=fn>void <a href="#killTimer"><b>killTimer</b></a> ( int id )</li>
|
---|
| 60 | <li class=fn>void <a href="#killTimers"><b>killTimers</b></a> ()</li>
|
---|
| 61 | <li class=fn>QObject * <a href="#child"><b>child</b></a> ( const char * objName, const char * inheritsClass = 0, bool recursiveSearch = TRUE )</li>
|
---|
| 62 | <li class=fn>const QObjectList * <a href="#children"><b>children</b></a> () const</li>
|
---|
| 63 | <li class=fn>QObjectList * <a href="#queryList"><b>queryList</b></a> ( const char * inheritsClass = 0, const char * objName = 0, bool regexpMatch = TRUE, bool recursiveSearch = TRUE ) const</li>
|
---|
| 64 | <li class=fn>virtual void <a href="#insertChild"><b>insertChild</b></a> ( QObject * obj )</li>
|
---|
| 65 | <li class=fn>virtual void <a href="#removeChild"><b>removeChild</b></a> ( QObject * obj )</li>
|
---|
| 66 | <li class=fn>void <a href="#installEventFilter"><b>installEventFilter</b></a> ( const QObject * filterObj )</li>
|
---|
| 67 | <li class=fn>void <a href="#removeEventFilter"><b>removeEventFilter</b></a> ( const QObject * obj )</li>
|
---|
| 68 | <li class=fn>bool <a href="#connect-2"><b>connect</b></a> ( const QObject * sender, const char * signal, const char * member ) const</li>
|
---|
| 69 | <li class=fn>bool <a href="#disconnect-2"><b>disconnect</b></a> ( const char * signal = 0, const QObject * receiver = 0, const char * member = 0 )</li>
|
---|
| 70 | <li class=fn>bool <a href="#disconnect-3"><b>disconnect</b></a> ( const QObject * receiver, const char * member = 0 )</li>
|
---|
| 71 | <li class=fn>void <a href="#dumpObjectTree"><b>dumpObjectTree</b></a> ()</li>
|
---|
| 72 | <li class=fn>void <a href="#dumpObjectInfo"><b>dumpObjectInfo</b></a> ()</li>
|
---|
| 73 | <li class=fn>virtual bool <a href="#setProperty"><b>setProperty</b></a> ( const char * name, const QVariant & value )</li>
|
---|
| 74 | <li class=fn>virtual QVariant <a href="#property"><b>property</b></a> ( const char * name ) const</li>
|
---|
| 75 | <li class=fn>QObject * <a href="#parent"><b>parent</b></a> () const</li>
|
---|
| 76 | </ul>
|
---|
| 77 | <h2>Public Slots</h2>
|
---|
| 78 | <ul>
|
---|
| 79 | <li class=fn>void <a href="#deleteLater"><b>deleteLater</b></a> ()</li>
|
---|
| 80 | </ul>
|
---|
| 81 | <h2>Signals</h2>
|
---|
| 82 | <ul>
|
---|
| 83 | <li class=fn>void <a href="#destroyed"><b>destroyed</b></a> ()</li>
|
---|
| 84 | <li class=fn>void <a href="#destroyed-2"><b>destroyed</b></a> ( QObject * obj )</li>
|
---|
| 85 | </ul>
|
---|
| 86 | <h2>Static Public Members</h2>
|
---|
| 87 | <ul>
|
---|
| 88 | <li class=fn>QString <a href="#tr"><b>tr</b></a> ( const char * sourceText, const char * comment )</li>
|
---|
| 89 | <li class=fn>QString <a href="#trUtf8"><b>trUtf8</b></a> ( const char * sourceText, const char * comment )</li>
|
---|
| 90 | <li class=fn>const QObjectList * <a href="#objectTrees"><b>objectTrees</b></a> ()</li>
|
---|
| 91 | <li class=fn>bool <a href="#connect"><b>connect</b></a> ( const QObject * sender, const char * signal, const QObject * receiver, const char * member )</li>
|
---|
| 92 | <li class=fn>bool <a href="#disconnect"><b>disconnect</b></a> ( const QObject * sender, const char * signal, const QObject * receiver, const char * member )</li>
|
---|
| 93 | </ul>
|
---|
| 94 | <h2>Properties</h2>
|
---|
| 95 | <ul>
|
---|
| 96 | <li class=fn>QCString <a href="#name-prop"><b>name</b></a> - the name of this object</li>
|
---|
| 97 | </ul>
|
---|
| 98 | <h2>Protected Members</h2>
|
---|
| 99 | <ul>
|
---|
| 100 | <li class=fn>const QObject * <a href="#sender"><b>sender</b></a> ()</li>
|
---|
| 101 | <li class=fn>virtual void <a href="#timerEvent"><b>timerEvent</b></a> ( QTimerEvent * )</li>
|
---|
| 102 | <li class=fn>virtual void <a href="#childEvent"><b>childEvent</b></a> ( QChildEvent * )</li>
|
---|
| 103 | <li class=fn>virtual void <a href="#customEvent"><b>customEvent</b></a> ( QCustomEvent * )</li>
|
---|
| 104 | <li class=fn>virtual void <a href="#connectNotify"><b>connectNotify</b></a> ( const char * signal )</li>
|
---|
| 105 | <li class=fn>virtual void <a href="#disconnectNotify"><b>disconnectNotify</b></a> ( const char * signal )</li>
|
---|
| 106 | <li class=fn>virtual bool <a href="#checkConnectArgs"><b>checkConnectArgs</b></a> ( const char * signal, const QObject * receiver, const char * member )</li>
|
---|
| 107 | </ul>
|
---|
| 108 | <h2>Static Protected Members</h2>
|
---|
| 109 | <ul>
|
---|
| 110 | <li class=fn>QCString <a href="#normalizeSignalSlot"><b>normalizeSignalSlot</b></a> ( const char * signalSlot )</li>
|
---|
| 111 | </ul>
|
---|
| 112 | <h2>Related Functions</h2>
|
---|
| 113 | <ul>
|
---|
| 114 | <li class=fn>void * <a href="#qt_find_obj_child"><b>qt_find_obj_child</b></a> ( QObject * parent, const char * type, const char * name )</li>
|
---|
| 115 | </ul>
|
---|
| 116 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | The QObject class is the base class of all Qt objects.
|
---|
| 120 | <p>
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | <p> QObject is the heart of the <a href="object.html">Qt object model.</a> The central feature in this model is a very powerful
|
---|
| 124 | mechanism for seamless object communication called <a href="signalsandslots.html">signals and slots</a>. You can
|
---|
| 125 | connect a signal to a slot with <a href="#connect">connect</a>() and destroy the
|
---|
| 126 | connection with <a href="#disconnect">disconnect</a>(). To avoid never ending notification
|
---|
| 127 | loops you can temporarily block signals with <a href="#blockSignals">blockSignals</a>(). The
|
---|
| 128 | protected functions <a href="#connectNotify">connectNotify</a>() and <a href="#disconnectNotify">disconnectNotify</a>() make it
|
---|
| 129 | possible to track connections.
|
---|
| 130 | <p> QObjects organize themselves in object trees. When you create a
|
---|
| 131 | QObject with another object as parent, the object will
|
---|
| 132 | automatically do an <a href="#insertChild">insertChild</a>() on the parent and thus show up
|
---|
| 133 | in the parent's <a href="#children">children</a>() list. The parent takes ownership of the
|
---|
| 134 | object i.e. it will automatically delete its children in its
|
---|
| 135 | destructor. You can look for an object by name and optionally type
|
---|
| 136 | using <a href="#child">child</a>() or <a href="#queryList">queryList</a>(), and get the list of tree roots using
|
---|
| 137 | <a href="#objectTrees">objectTrees</a>().
|
---|
| 138 | <p> Every object has an object <a href="#name">name</a>() and can report its <a href="#className">className</a>()
|
---|
| 139 | and whether it <a href="#inherits">inherits</a>() another class in the QObject inheritance
|
---|
| 140 | hierarchy.
|
---|
| 141 | <p> When an object is deleted, it emits a <a href="#destroyed">destroyed</a>() signal. You can
|
---|
| 142 | catch this signal to avoid dangling references to QObjects. The
|
---|
| 143 | <a href="qguardedptr.html">QGuardedPtr</a> class provides an elegant way to use this feature.
|
---|
| 144 | <p> QObjects can receive events through <a href="#event">event</a>() and filter the events
|
---|
| 145 | of other objects. See <a href="#installEventFilter">installEventFilter</a>() and <a href="#eventFilter">eventFilter</a>() for
|
---|
| 146 | details. A convenience handler, <a href="#childEvent">childEvent</a>(), can be reimplemented
|
---|
| 147 | to catch child events.
|
---|
| 148 | <p> Last but not least, QObject provides the basic timer support in
|
---|
| 149 | Qt; see <a href="qtimer.html">QTimer</a> for high-level support for timers.
|
---|
| 150 | <p> Notice that the <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> macro is mandatory for any object that
|
---|
| 151 | implements signals, slots or properties. You also need to run the
|
---|
| 152 | <a href="moc.html">moc program (Meta Object Compiler)</a> on the
|
---|
| 153 | source file. We strongly recommend the use of this macro in <em>all</em>
|
---|
| 154 | subclasses of QObject regardless of whether or not they actually
|
---|
| 155 | use signals, slots and properties, since failure to do so may lead
|
---|
| 156 | certain functions to exhibit undefined behaviour.
|
---|
| 157 | <p> All Qt widgets inherit QObject. The convenience function
|
---|
| 158 | <a href="#isWidgetType">isWidgetType</a>() returns whether an object is actually a widget. It
|
---|
| 159 | is much faster than <a href="#inherits">inherits</a>( "QWidget" ).
|
---|
| 160 | <p> Some QObject functions, e.g. <a href="#children">children</a>(), <a href="#objectTrees">objectTrees</a>() and
|
---|
| 161 | <a href="#queryList">queryList</a>() return a <a href="qobjectlist.html">QObjectList</a>. A QObjectList is a <a href="qptrlist.html">QPtrList</a> of
|
---|
| 162 | QObjects. QObjectLists support the same operations as QPtrLists
|
---|
| 163 | and have an iterator class, QObjectListIt.
|
---|
| 164 | <p>See also <a href="objectmodel.html">Object Model</a>.
|
---|
| 165 |
|
---|
| 166 | <hr><h2>Member Function Documentation</h2>
|
---|
| 167 | <h3 class=fn><a name="QObject"></a>QObject::QObject ( <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
---|
| 168 | </h3>
|
---|
| 169 | Constructs an object called <em>name</em> with parent object, <em>parent</em>.
|
---|
| 170 | <p> The parent of an object may be viewed as the object's owner. For
|
---|
| 171 | instance, a <a href="qdialog.html">dialog box</a> is the parent of the
|
---|
| 172 | "OK" and "Cancel" buttons it contains.
|
---|
| 173 | <p> The destructor of a parent object destroys all child objects.
|
---|
| 174 | <p> Setting <em>parent</em> to 0 constructs an object with no parent. If the
|
---|
| 175 | object is a widget, it will become a top-level window.
|
---|
| 176 | <p> The object name is some text that can be used to identify a
|
---|
| 177 | QObject. It's particularly useful in conjunction with <a href="designer-manual.html"><i>Qt Designer</i></a>. You can find an
|
---|
| 178 | object by name (and type) using <a href="#child">child</a>(). To find several objects
|
---|
| 179 | use <a href="#queryList">queryList</a>().
|
---|
| 180 | <p> <p>See also <a href="#parent">parent</a>(), <a href="#name-prop">name</a>, <a href="#child">child</a>(), and <a href="#queryList">queryList</a>().
|
---|
| 181 |
|
---|
| 182 | <h3 class=fn><a name="~QObject"></a>QObject::~QObject ()<tt> [virtual]</tt>
|
---|
| 183 | </h3>
|
---|
| 184 | Destroys the object, deleting all its child objects.
|
---|
| 185 | <p> All signals to and from the object are automatically disconnected.
|
---|
| 186 | <p> <b>Warning:</b> All child objects are deleted. If any of these objects
|
---|
| 187 | are on the stack or global, sooner or later your program will
|
---|
| 188 | crash. We do not recommend holding pointers to child objects from
|
---|
| 189 | outside the parent. If you still do, the <a href="#destroyed">QObject::destroyed</a>()
|
---|
| 190 | signal gives you an opportunity to detect when an object is
|
---|
| 191 | destroyed.
|
---|
| 192 | <p> <b>Warning:</b> Deleting a QObject while pending events are waiting to be
|
---|
| 193 | delivered can cause a crash. You must not delete the QObject
|
---|
| 194 | directly from a thread that is not the GUI thread. Use the
|
---|
| 195 | <a href="#deleteLater">QObject::deleteLater</a>() method instead, which will cause the event
|
---|
| 196 | loop to delete the object after all pending events have been
|
---|
| 197 | delivered to the object.
|
---|
| 198 |
|
---|
| 199 | <h3 class=fn>void <a name="blockSignals"></a>QObject::blockSignals ( bool block )
|
---|
| 200 | </h3>
|
---|
| 201 | Blocks signals if <em>block</em> is TRUE, or unblocks signals if <em>block</em> is FALSE.
|
---|
| 202 | <p> Emitted signals disappear into hyperspace if signals are blocked.
|
---|
| 203 | Note that the <a href="#destroyed">destroyed</a>() signals will be emitted even if the signals
|
---|
| 204 | for this object have been blocked.
|
---|
| 205 |
|
---|
| 206 | <p>Examples: <a href="rot-example.html#x1371">rot13/rot13.cpp</a> and <a href="qaxserver-example-simple.html#x2525">simple/main.cpp</a>.
|
---|
| 207 | <h3 class=fn>bool <a name="checkConnectArgs"></a>QObject::checkConnectArgs ( const char * signal, const <a href="qobject.html">QObject</a> * receiver, const char * member )<tt> [virtual protected]</tt>
|
---|
| 208 | </h3>
|
---|
| 209 |
|
---|
| 210 | <p> Returns TRUE if the <em>signal</em> and the <em>member</em> arguments are
|
---|
| 211 | compatible; otherwise returns FALSE. (The <em>receiver</em> argument is
|
---|
| 212 | currently ignored.)
|
---|
| 213 | <p> <b>Warning:</b> We recommend that you use the default implementation and
|
---|
| 214 | do not reimplement this function.
|
---|
| 215 | <p>
|
---|
| 216 |
|
---|
| 217 | <h3 class=fn><a href="qobject.html">QObject</a> * <a name="child"></a>QObject::child ( const char * objName, const char * inheritsClass = 0, bool recursiveSearch = TRUE )
|
---|
| 218 | </h3>
|
---|
| 219 | Searches the children and optionally grandchildren of this object,
|
---|
| 220 | and returns a child that is called <em>objName</em> that inherits <em>inheritsClass</em>. If <em>inheritsClass</em> is 0 (the default), any class
|
---|
| 221 | matches.
|
---|
| 222 | <p> If <em>recursiveSearch</em> is TRUE (the default), <a href="#child">child</a>() performs a
|
---|
| 223 | depth-first search of the object's children.
|
---|
| 224 | <p> If there is no such object, this function returns 0. If there are
|
---|
| 225 | more than one, the first one found is retured; if you need all of
|
---|
| 226 | them, use <a href="#queryList">queryList</a>().
|
---|
| 227 |
|
---|
| 228 | <h3 class=fn>void <a name="childEvent"></a>QObject::childEvent ( <a href="qchildevent.html">QChildEvent</a> * )<tt> [virtual protected]</tt>
|
---|
| 229 | </h3>
|
---|
| 230 | This event handler can be reimplemented in a subclass to receive
|
---|
| 231 | child events.
|
---|
| 232 | <p> Child events are sent to objects when children are inserted or
|
---|
| 233 | removed.
|
---|
| 234 | <p> Note that events with <a href="qevent.html#type">QEvent::type</a>() <a href="qevent.html#Type-enum">QEvent::ChildInserted</a> are
|
---|
| 235 | posted (with <a href="qapplication.html#postEvent">QApplication::postEvent</a>()) to make sure that the
|
---|
| 236 | child's construction is completed before this function is called.
|
---|
| 237 | <p> If a child is removed immediately after it is inserted, the <tt>ChildInserted</tt> event may be suppressed, but the <tt>ChildRemoved</tt>
|
---|
| 238 | event will always be sent. In such cases it is possible that there
|
---|
| 239 | will be a <tt>ChildRemoved</tt> event without a corresponding <tt>ChildInserted</tt> event.
|
---|
| 240 | <p> If you change state based on <tt>ChildInserted</tt> events, call
|
---|
| 241 | <a href="qwidget.html#constPolish">QWidget::constPolish</a>(), or do
|
---|
| 242 | <pre>
|
---|
| 243 | QApplication::<a href="qapplication.html#sendPostedEvents">sendPostedEvents</a>( this, QEvent::ChildInserted );
|
---|
| 244 | </pre>
|
---|
| 245 |
|
---|
| 246 | in functions that depend on the state. One notable example is
|
---|
| 247 | <a href="qwidget.html#sizeHint">QWidget::sizeHint</a>().
|
---|
| 248 | <p> <p>See also <a href="#event">event</a>() and <a href="qchildevent.html">QChildEvent</a>.
|
---|
| 249 |
|
---|
| 250 | <p>Reimplemented in <a href="qmainwindow.html#childEvent">QMainWindow</a> and <a href="qsplitter.html#childEvent">QSplitter</a>.
|
---|
| 251 | <h3 class=fn>const <a href="qobjectlist.html">QObjectList</a> * <a name="children"></a>QObject::children () const
|
---|
| 252 | </h3>
|
---|
| 253 |
|
---|
| 254 | <p> Returns a list of child objects, or 0 if this object has no
|
---|
| 255 | children.
|
---|
| 256 | <p> The <a href="qobjectlist.html">QObjectList</a> class is defined in the <a href="qobjectlist-h.html">qobjectlist.h</a> header
|
---|
| 257 | file.
|
---|
| 258 | <p> The first child added is the <a href="qptrlist.html#first">first</a>
|
---|
| 259 | object in the list and the last child added is the <a href="qptrlist.html#last">last</a> object in the list, i.e. new
|
---|
| 260 | children are appended at the end.
|
---|
| 261 | <p> Note that the list order changes when <a href="qwidget.html">QWidget</a> children are <a href="qwidget.html#raise">raised</a> or <a href="qwidget.html#lower">lowered.</a> A widget that is raised becomes the last object
|
---|
| 262 | in the list, and a widget that is lowered becomes the first object
|
---|
| 263 | in the list.
|
---|
| 264 | <p> <p>See also <a href="#child">child</a>(), <a href="#queryList">queryList</a>(), <a href="#parent">parent</a>(), <a href="#insertChild">insertChild</a>(), and <a href="#removeChild">removeChild</a>().
|
---|
| 265 |
|
---|
| 266 | <h3 class=fn>const char * <a name="className"></a>QObject::className () const<tt> [virtual]</tt>
|
---|
| 267 | </h3>
|
---|
| 268 |
|
---|
| 269 | <p> Returns the class name of this object.
|
---|
| 270 | <p> This function is generated by the <a href="metaobjects.html">Meta
|
---|
| 271 | Object Compiler.</a>
|
---|
| 272 | <p> <b>Warning:</b> This function will return the wrong name if the class
|
---|
| 273 | definition lacks the <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> macro.
|
---|
| 274 | <p> <p>See also <a href="#name-prop">name</a>, <a href="#inherits">inherits</a>(), <a href="#isA">isA</a>(), and <a href="#isWidgetType">isWidgetType</a>().
|
---|
| 275 |
|
---|
| 276 | <p>Example: <a href="sql.html#x2235">sql/overview/custom1/main.cpp</a>.
|
---|
| 277 | <h3 class=fn>bool <a name="connect"></a>QObject::connect ( const <a href="qobject.html">QObject</a> * sender, const char * signal, const <a href="qobject.html">QObject</a> * receiver, const char * member )<tt> [static]</tt>
|
---|
| 278 | </h3>
|
---|
| 279 | Connects <em>signal</em> from the <em>sender</em> object to <em>member</em> in object
|
---|
| 280 | <em>receiver</em>, and returns TRUE if the connection succeeds; otherwise
|
---|
| 281 | returns FALSE.
|
---|
| 282 | <p> You must use the SIGNAL() and SLOT() macros when specifying the <em>signal</em>
|
---|
| 283 | and the <em>member</em>, for example:
|
---|
| 284 | <pre>
|
---|
| 285 | <a href="qlabel.html">QLabel</a> *label = new <a href="qlabel.html">QLabel</a>;
|
---|
| 286 | <a href="qscrollbar.html">QScrollBar</a> *scroll = new <a href="qscrollbar.html">QScrollBar</a>;
|
---|
| 287 | QObject::<a href="#connect">connect</a>( scroll, SIGNAL(<a href="qscrollbar.html#valueChanged">valueChanged</a>(int)),
|
---|
| 288 | label, SLOT(<a href="qlabel.html#setNum">setNum</a>(int)) );
|
---|
| 289 | </pre>
|
---|
| 290 |
|
---|
| 291 | <p> This example ensures that the label always displays the current
|
---|
| 292 | scroll bar value. Note that the signal and slots parameters must not
|
---|
| 293 | contain any variable names, only the type. E.g. the following would
|
---|
| 294 | not work and return FALSE:
|
---|
| 295 | <a href="#connect">QObject::connect</a>( scroll, SIGNAL(valueChanged(int v)),
|
---|
| 296 | label, SLOT(setNum(int v)) );
|
---|
| 297 | <p> A signal can also be connected to another signal:
|
---|
| 298 | <p> <pre>
|
---|
| 299 | class MyWidget : public <a href="qwidget.html">QWidget</a>
|
---|
| 300 | {
|
---|
| 301 | <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a>
|
---|
| 302 | public:
|
---|
| 303 | MyWidget();
|
---|
| 304 |
|
---|
| 305 | signals:
|
---|
| 306 | void myUsefulSignal();
|
---|
| 307 |
|
---|
| 308 | private:
|
---|
| 309 | <a href="qpushbutton.html">QPushButton</a> *aButton;
|
---|
| 310 | };
|
---|
| 311 |
|
---|
| 312 | MyWidget::MyWidget()
|
---|
| 313 | {
|
---|
| 314 | aButton = new <a href="qpushbutton.html">QPushButton</a>( this );
|
---|
| 315 | <a href="#connect">connect</a>( aButton, SIGNAL(<a href="qbutton.html#clicked">clicked</a>()), SIGNAL(myUsefulSignal()) );
|
---|
| 316 | }
|
---|
| 317 | </pre>
|
---|
| 318 |
|
---|
| 319 | <p> In this example, the MyWidget constructor relays a signal from a
|
---|
| 320 | private member variable, and makes it available under a name that
|
---|
| 321 | relates to MyWidget.
|
---|
| 322 | <p> A signal can be connected to many slots and signals. Many signals
|
---|
| 323 | can be connected to one slot.
|
---|
| 324 | <p> If a signal is connected to several slots, the slots are activated
|
---|
| 325 | in an arbitrary order when the signal is emitted.
|
---|
| 326 | <p> The function returns TRUE if it successfully connects the signal
|
---|
| 327 | to the slot. It will return FALSE if it cannot create the
|
---|
| 328 | connection, for example, if QObject is unable to verify the
|
---|
| 329 | existence of either <em>signal</em> or <em>member</em>, or if their signatures
|
---|
| 330 | aren't compatible.
|
---|
| 331 | <p> A signal is emitted for <em>every</em> connection you make, so if you
|
---|
| 332 | duplicate a connection, two signals will be emitted. You can
|
---|
| 333 | always break a connection using <a href="#disconnect">disconnect</a>().
|
---|
| 334 | <p> <p>See also <a href="#disconnect">disconnect</a>().
|
---|
| 335 |
|
---|
| 336 | <p>Examples: <a href="qaction-application-example.html#x1179">action/main.cpp</a>, <a href="simple-application-example.html#x1599">application/main.cpp</a>, <a href="extension-dialog-example.html#x2868">extension/main.cpp</a>, <a href="iconview-example.html#x1460">iconview/main.cpp</a>, <a href="archivesearch-example.html#x489">network/archivesearch/main.cpp</a>, <a href="regexptester-example.html#x2512">regexptester/main.cpp</a>, and <a href="tutorial1-02.html#x2291">t2/main.cpp</a>.
|
---|
| 337 | <h3 class=fn>bool <a name="connect-2"></a>QObject::connect ( const <a href="qobject.html">QObject</a> * sender, const char * signal, const char * member ) const
|
---|
| 338 | </h3>
|
---|
| 339 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 340 | <p> Connects <em>signal</em> from the <em>sender</em> object to this object's <em>member</em>.
|
---|
| 341 | <p> Equivalent to: <tt>QObject::connect(sender, signal, this, member)</tt>.
|
---|
| 342 | <p> <p>See also <a href="#disconnect">disconnect</a>().
|
---|
| 343 |
|
---|
| 344 | <h3 class=fn>void <a name="connectNotify"></a>QObject::connectNotify ( const char * signal )<tt> [virtual protected]</tt>
|
---|
| 345 | </h3>
|
---|
| 346 |
|
---|
| 347 | <p> This virtual function is called when something has been connected
|
---|
| 348 | to <em>signal</em> in this object.
|
---|
| 349 | <p> <b>Warning:</b> This function violates the object-oriented principle of
|
---|
| 350 | modularity. However, it might be useful when you need to perform
|
---|
| 351 | expensive initialization only if something is connected to a
|
---|
| 352 | signal.
|
---|
| 353 | <p> <p>See also <a href="#connect">connect</a>() and <a href="#disconnectNotify">disconnectNotify</a>().
|
---|
| 354 |
|
---|
| 355 | <h3 class=fn>void <a name="customEvent"></a>QObject::customEvent ( <a href="qcustomevent.html">QCustomEvent</a> * )<tt> [virtual protected]</tt>
|
---|
| 356 | </h3>
|
---|
| 357 | This event handler can be reimplemented in a subclass to receive
|
---|
| 358 | custom events. Custom events are user-defined events with a type
|
---|
| 359 | value at least as large as the "User" item of the <a href="qevent.html#Type-enum">QEvent::Type</a>
|
---|
| 360 | enum, and is typically a <a href="qcustomevent.html">QCustomEvent</a> or QCustomEvent subclass.
|
---|
| 361 | <p> <p>See also <a href="#event">event</a>() and <a href="qcustomevent.html">QCustomEvent</a>.
|
---|
| 362 |
|
---|
| 363 | <h3 class=fn>void <a name="deleteLater"></a>QObject::deleteLater ()<tt> [slot]</tt>
|
---|
| 364 | </h3>
|
---|
| 365 | Performs a deferred deletion of this object.
|
---|
| 366 | <p> Instead of an immediate deletion this function schedules a
|
---|
| 367 | deferred delete event for processing when Qt returns to the main
|
---|
| 368 | event loop.
|
---|
| 369 |
|
---|
| 370 | <p>Example: <a href="bigtable-example.html#x1290">table/bigtable/main.cpp</a>.
|
---|
| 371 | <h3 class=fn>void <a name="destroyed"></a>QObject::destroyed ()<tt> [signal]</tt>
|
---|
| 372 | </h3>
|
---|
| 373 |
|
---|
| 374 | <p> This signal is emitted when the object is being destroyed.
|
---|
| 375 | <p> Note that the signal is emitted by the QObject destructor, so
|
---|
| 376 | the object's virtual table is already degenerated at this point,
|
---|
| 377 | and it is not safe to call any functions on the object emitting
|
---|
| 378 | the signal. This signal can not be blocked.
|
---|
| 379 | <p> All the objects's children are destroyed immediately after this
|
---|
| 380 | signal is emitted.
|
---|
| 381 |
|
---|
| 382 | <h3 class=fn>void <a name="destroyed-2"></a>QObject::destroyed ( <a href="qobject.html">QObject</a> * obj )<tt> [signal]</tt>
|
---|
| 383 | </h3>
|
---|
| 384 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 385 | <p> This signal is emitted immediately before the object <em>obj</em> is
|
---|
| 386 | destroyed, and can not be blocked.
|
---|
| 387 | <p> All the objects's children are destroyed immediately after this
|
---|
| 388 | signal is emitted.
|
---|
| 389 |
|
---|
| 390 | <h3 class=fn>bool <a name="disconnect"></a>QObject::disconnect ( const <a href="qobject.html">QObject</a> * sender, const char * signal, const <a href="qobject.html">QObject</a> * receiver, const char * member )<tt> [static]</tt>
|
---|
| 391 | </h3>
|
---|
| 392 | Disconnects <em>signal</em> in object <em>sender</em> from <em>member</em> in object
|
---|
| 393 | <em>receiver</em>.
|
---|
| 394 | <p> A signal-slot connection is removed when either of the objects
|
---|
| 395 | involved are destroyed.
|
---|
| 396 | <p> <a href="#disconnect">disconnect</a>() is typically used in three ways, as the following
|
---|
| 397 | examples demonstrate.
|
---|
| 398 | <ol type=1>
|
---|
| 399 | <li> Disconnect everything connected to an object's signals:
|
---|
| 400 | <pre>
|
---|
| 401 | <a href="#disconnect">disconnect</a>( myObject, 0, 0, 0 );
|
---|
| 402 | </pre>
|
---|
| 403 |
|
---|
| 404 | equivalent to the non-static overloaded function
|
---|
| 405 | <pre>
|
---|
| 406 | myObject->disconnect();
|
---|
| 407 | </pre>
|
---|
| 408 |
|
---|
| 409 | <li> Disconnect everything connected to a specific signal:
|
---|
| 410 | <pre>
|
---|
| 411 | <a href="#disconnect">disconnect</a>( myObject, SIGNAL(mySignal()), 0, 0 );
|
---|
| 412 | </pre>
|
---|
| 413 |
|
---|
| 414 | equivalent to the non-static overloaded function
|
---|
| 415 | <pre>
|
---|
| 416 | myObject->disconnect( SIGNAL(mySignal()) );
|
---|
| 417 | </pre>
|
---|
| 418 |
|
---|
| 419 | <li> Disconnect a specific receiver:
|
---|
| 420 | <pre>
|
---|
| 421 | <a href="#disconnect">disconnect</a>( myObject, 0, myReceiver, 0 );
|
---|
| 422 | </pre>
|
---|
| 423 |
|
---|
| 424 | equivalent to the non-static overloaded function
|
---|
| 425 | <pre>
|
---|
| 426 | myObject->disconnect( myReceiver );
|
---|
| 427 | </pre>
|
---|
| 428 |
|
---|
| 429 | </ol>
|
---|
| 430 | <p> 0 may be used as a wildcard, meaning "any signal", "any receiving
|
---|
| 431 | object", or "any slot in the receiving object", respectively.
|
---|
| 432 | <p> The <em>sender</em> may never be 0. (You cannot disconnect signals from
|
---|
| 433 | more than one object in a single call.)
|
---|
| 434 | <p> If <em>signal</em> is 0, it disconnects <em>receiver</em> and <em>member</em> from
|
---|
| 435 | any signal. If not, only the specified signal is disconnected.
|
---|
| 436 | <p> If <em>receiver</em> is 0, it disconnects anything connected to <em>signal</em>. If not, slots in objects other than <em>receiver</em> are not
|
---|
| 437 | disconnected.
|
---|
| 438 | <p> If <em>member</em> is 0, it disconnects anything that is connected to <em>receiver</em>. If not, only slots named <em>member</em> will be disconnected,
|
---|
| 439 | and all other slots are left alone. The <em>member</em> must be 0 if <em>receiver</em> is left out, so you cannot disconnect a
|
---|
| 440 | specifically-named slot on all objects.
|
---|
| 441 | <p> <p>See also <a href="#connect">connect</a>().
|
---|
| 442 |
|
---|
| 443 | <h3 class=fn>bool <a name="disconnect-2"></a>QObject::disconnect ( const char * signal = 0, const <a href="qobject.html">QObject</a> * receiver = 0, const char * member = 0 )
|
---|
| 444 | </h3>
|
---|
| 445 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 446 | <p> Disconnects <em>signal</em> from <em>member</em> of <em>receiver</em>.
|
---|
| 447 | <p> A signal-slot connection is removed when either of the objects
|
---|
| 448 | involved are destroyed.
|
---|
| 449 |
|
---|
| 450 | <h3 class=fn>bool <a name="disconnect-3"></a>QObject::disconnect ( const <a href="qobject.html">QObject</a> * receiver, const char * member = 0 )
|
---|
| 451 | </h3>
|
---|
| 452 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 453 | <p> Disconnects all signals in this object from <em>receiver</em>'s <em>member</em>.
|
---|
| 454 | <p> A signal-slot connection is removed when either of the objects
|
---|
| 455 | involved are destroyed.
|
---|
| 456 |
|
---|
| 457 | <h3 class=fn>void <a name="disconnectNotify"></a>QObject::disconnectNotify ( const char * signal )<tt> [virtual protected]</tt>
|
---|
| 458 | </h3>
|
---|
| 459 |
|
---|
| 460 | <p> This virtual function is called when something has been
|
---|
| 461 | disconnected from <em>signal</em> in this object.
|
---|
| 462 | <p> <b>Warning:</b> This function violates the object-oriented principle of
|
---|
| 463 | modularity. However, it might be useful for optimizing access to
|
---|
| 464 | expensive resources.
|
---|
| 465 | <p> <p>See also <a href="#disconnect">disconnect</a>() and <a href="#connectNotify">connectNotify</a>().
|
---|
| 466 |
|
---|
| 467 | <h3 class=fn>void <a name="dumpObjectInfo"></a>QObject::dumpObjectInfo ()
|
---|
| 468 | </h3>
|
---|
| 469 | Dumps information about signal connections, etc. for this object
|
---|
| 470 | to the debug output.
|
---|
| 471 | <p> This function is useful for debugging, but does nothing if the
|
---|
| 472 | library has been compiled in release mode (i.e. without debugging
|
---|
| 473 | information).
|
---|
| 474 |
|
---|
| 475 | <h3 class=fn>void <a name="dumpObjectTree"></a>QObject::dumpObjectTree ()
|
---|
| 476 | </h3>
|
---|
| 477 | Dumps a tree of children to the debug output.
|
---|
| 478 | <p> This function is useful for debugging, but does nothing if the
|
---|
| 479 | library has been compiled in release mode (i.e. without debugging
|
---|
| 480 | information).
|
---|
| 481 |
|
---|
| 482 | <h3 class=fn>bool <a name="event"></a>QObject::event ( <a href="qevent.html">QEvent</a> * e )<tt> [virtual]</tt>
|
---|
| 483 | </h3>
|
---|
| 484 | This virtual function receives events to an object and should
|
---|
| 485 | return TRUE if the event <em>e</em> was recognized and processed.
|
---|
| 486 | <p> The <a href="#event">event</a>() function can be reimplemented to customize the
|
---|
| 487 | behavior of an object.
|
---|
| 488 | <p> <p>See also <a href="#installEventFilter">installEventFilter</a>(), <a href="#timerEvent">timerEvent</a>(), <a href="qapplication.html#sendEvent">QApplication::sendEvent</a>(), <a href="qapplication.html#postEvent">QApplication::postEvent</a>(), and <a href="qwidget.html#event">QWidget::event</a>().
|
---|
| 489 |
|
---|
| 490 | <p>Reimplemented in <a href="qwidget.html#event">QWidget</a>.
|
---|
| 491 | <h3 class=fn>bool <a name="eventFilter"></a>QObject::eventFilter ( <a href="qobject.html">QObject</a> * watched, <a href="qevent.html">QEvent</a> * e )<tt> [virtual]</tt>
|
---|
| 492 | </h3>
|
---|
| 493 | Filters events if this object has been installed as an event
|
---|
| 494 | filter for the <em>watched</em> object.
|
---|
| 495 | <p> In your reimplementation of this function, if you want to filter
|
---|
| 496 | the event <em>e</em>, out, i.e. stop it being handled further, return
|
---|
| 497 | TRUE; otherwise return FALSE.
|
---|
| 498 | <p> Example:
|
---|
| 499 | <pre>
|
---|
| 500 | class MyMainWindow : public <a href="qmainwindow.html">QMainWindow</a>
|
---|
| 501 | {
|
---|
| 502 | public:
|
---|
| 503 | MyMainWindow( <a href="qwidget.html">QWidget</a> *parent = 0, const char *name = 0 );
|
---|
| 504 |
|
---|
| 505 | protected:
|
---|
| 506 | bool eventFilter( QObject *obj, QEvent *ev );
|
---|
| 507 |
|
---|
| 508 | private:
|
---|
| 509 | <a href="qtextedit.html">QTextEdit</a> *textEdit;
|
---|
| 510 | };
|
---|
| 511 |
|
---|
| 512 | MyMainWindow::MyMainWindow( <a href="qwidget.html">QWidget</a> *parent, const char *name )
|
---|
| 513 | : <a href="qmainwindow.html">QMainWindow</a>( parent, name )
|
---|
| 514 | {
|
---|
| 515 | textEdit = new <a href="qtextedit.html">QTextEdit</a>( this );
|
---|
| 516 | <a href="qmainwindow.html#setCentralWidget">setCentralWidget</a>( textEdit );
|
---|
| 517 | textEdit-><a href="#installEventFilter">installEventFilter</a>( this );
|
---|
| 518 | }
|
---|
| 519 |
|
---|
| 520 | bool MyMainWindow::<a href="#eventFilter">eventFilter</a>( QObject *obj, QEvent *ev )
|
---|
| 521 | {
|
---|
| 522 | if ( obj == textEdit ) {
|
---|
| 523 | if ( e->type() == QEvent::KeyPress ) {
|
---|
| 524 | <a href="qkeyevent.html">QKeyEvent</a> *k = (QKeyEvent*)ev;
|
---|
| 525 | <a href="qapplication.html#qDebug">qDebug</a>( "Ate key press %d", k-><a href="qkeyevent.html#key">key</a>() );
|
---|
| 526 | return TRUE;
|
---|
| 527 | } else {
|
---|
| 528 | return FALSE;
|
---|
| 529 | }
|
---|
| 530 | } else {
|
---|
| 531 | // pass the event on to the parent class
|
---|
| 532 | return QMainWindow::eventFilter( obj, ev );
|
---|
| 533 | }
|
---|
| 534 | }
|
---|
| 535 | </pre>
|
---|
| 536 |
|
---|
| 537 | <p> Notice in the example above that unhandled events are passed to
|
---|
| 538 | the base class's <a href="#eventFilter">eventFilter</a>() function, since the base class
|
---|
| 539 | might have reimplemented eventFilter() for its own internal
|
---|
| 540 | purposes.
|
---|
| 541 | <p> <b>Warning:</b> If you delete the receiver object in this function, be
|
---|
| 542 | sure to return TRUE. Otherwise, Qt will forward the event to the
|
---|
| 543 | deleted object and the program might crash.
|
---|
| 544 | <p> <p>See also <a href="#installEventFilter">installEventFilter</a>().
|
---|
| 545 |
|
---|
| 546 | <p>Reimplemented in <a href="qaccel.html#eventFilter">QAccel</a>, <a href="qscrollview.html#eventFilter">QScrollView</a>, and <a href="qspinbox.html#eventFilter">QSpinBox</a>.
|
---|
| 547 | <h3 class=fn>bool <a name="highPriority"></a>QObject::highPriority () const
|
---|
| 548 | </h3>
|
---|
| 549 |
|
---|
| 550 | <p> Returns TRUE if the object is a high-priority object, or FALSE if
|
---|
| 551 | it is a standard-priority object.
|
---|
| 552 | <p> High-priority objects are placed first in QObject's list of
|
---|
| 553 | children on the assumption that they will be referenced very
|
---|
| 554 | often.
|
---|
| 555 |
|
---|
| 556 | <h3 class=fn>bool <a name="inherits"></a>QObject::inherits ( const char * clname ) const
|
---|
| 557 | </h3>
|
---|
| 558 | Returns TRUE if this object is an instance of a class that
|
---|
| 559 | inherits <em>clname</em>, and <em>clname</em> inherits QObject; otherwise
|
---|
| 560 | returns FALSE.
|
---|
| 561 | <p> A class is considered to inherit itself.
|
---|
| 562 | <p> Example:
|
---|
| 563 | <pre>
|
---|
| 564 | <a href="qtimer.html">QTimer</a> *t = new <a href="qtimer.html">QTimer</a>; // QTimer inherits QObject
|
---|
| 565 | t-><a href="#inherits">inherits</a>( "QTimer" ); // returns TRUE
|
---|
| 566 | t-><a href="#inherits">inherits</a>( "QObject" ); // returns TRUE
|
---|
| 567 | t-><a href="#inherits">inherits</a>( "QButton" ); // returns FALSE
|
---|
| 568 |
|
---|
| 569 | // QScrollBar inherits QWidget and QRangeControl
|
---|
| 570 | <a href="qscrollbar.html">QScrollBar</a> *s = new <a href="qscrollbar.html">QScrollBar</a>( 0 );
|
---|
| 571 | s-><a href="#inherits">inherits</a>( "QWidget" ); // returns TRUE
|
---|
| 572 | s-><a href="#inherits">inherits</a>( "QRangeControl" ); // returns FALSE
|
---|
| 573 | </pre>
|
---|
| 574 |
|
---|
| 575 | <p> (<a href="qrangecontrol.html">QRangeControl</a> is not a QObject.)
|
---|
| 576 | <p> <p>See also <a href="#isA">isA</a>() and <a href="#metaObject">metaObject</a>().
|
---|
| 577 |
|
---|
| 578 | <p>Examples: <a href="statistics-example.html#x2783">table/statistics/statistics.cpp</a>, <a href="themes-example.html#x282">themes/metal.cpp</a>, and <a href="themes-example.html#x211">themes/wood.cpp</a>.
|
---|
| 579 | <h3 class=fn>void <a name="insertChild"></a>QObject::insertChild ( <a href="qobject.html">QObject</a> * obj )<tt> [virtual]</tt>
|
---|
| 580 | </h3>
|
---|
| 581 | Inserts an object <em>obj</em> into the list of child objects.
|
---|
| 582 | <p> <b>Warning:</b> This function cannot be used to make one widget the child
|
---|
| 583 | widget of another widget. Child widgets can only be created by
|
---|
| 584 | setting the parent widget in the constructor or by calling
|
---|
| 585 | <a href="qwidget.html#reparent">QWidget::reparent</a>().
|
---|
| 586 | <p> <p>See also <a href="#removeChild">removeChild</a>() and <a href="qwidget.html#reparent">QWidget::reparent</a>().
|
---|
| 587 |
|
---|
| 588 | <h3 class=fn>void <a name="installEventFilter"></a>QObject::installEventFilter ( const <a href="qobject.html">QObject</a> * filterObj )
|
---|
| 589 | </h3>
|
---|
| 590 |
|
---|
| 591 | <p> Installs an event filter <em>filterObj</em> on this object. For example:
|
---|
| 592 | <pre>
|
---|
| 593 | monitoredObj->installEventFilter( filterObj );
|
---|
| 594 | </pre>
|
---|
| 595 |
|
---|
| 596 | <p> An event filter is an object that receives all events that are
|
---|
| 597 | sent to this object. The filter can either stop the event or
|
---|
| 598 | forward it to this object. The event filter <em>filterObj</em> receives
|
---|
| 599 | events via its <a href="#eventFilter">eventFilter</a>() function. The eventFilter() function
|
---|
| 600 | must return TRUE if the event should be filtered, (i.e. stopped);
|
---|
| 601 | otherwise it must return FALSE.
|
---|
| 602 | <p> If multiple event filters are installed on a single object, the
|
---|
| 603 | filter that was installed last is activated first.
|
---|
| 604 | <p> Here's a <tt>KeyPressEater</tt> class that eats the key presses of its
|
---|
| 605 | monitored objects:
|
---|
| 606 | <pre>
|
---|
| 607 | class KeyPressEater : public QObject
|
---|
| 608 | {
|
---|
| 609 | ...
|
---|
| 610 | protected:
|
---|
| 611 | bool eventFilter( QObject *o, QEvent *e );
|
---|
| 612 | };
|
---|
| 613 |
|
---|
| 614 | bool KeyPressEater::<a href="#eventFilter">eventFilter</a>( QObject *o, QEvent *e )
|
---|
| 615 | {
|
---|
| 616 | if ( e->type() == QEvent::KeyPress ) {
|
---|
| 617 | // special processing for key press
|
---|
| 618 | <a href="qkeyevent.html">QKeyEvent</a> *k = (QKeyEvent *)e;
|
---|
| 619 | <a href="qapplication.html#qDebug">qDebug</a>( "Ate key press %d", k-><a href="qkeyevent.html#key">key</a>() );
|
---|
| 620 | return TRUE; // eat event
|
---|
| 621 | } else {
|
---|
| 622 | // standard event processing
|
---|
| 623 | return FALSE;
|
---|
| 624 | }
|
---|
| 625 | }
|
---|
| 626 | </pre>
|
---|
| 627 |
|
---|
| 628 | <p> And here's how to install it on two widgets:
|
---|
| 629 | <pre>
|
---|
| 630 | KeyPressEater *keyPressEater = new KeyPressEater( this );
|
---|
| 631 | <a href="qpushbutton.html">QPushButton</a> *pushButton = new <a href="qpushbutton.html">QPushButton</a>( this );
|
---|
| 632 | <a href="qlistview.html">QListView</a> *listView = new <a href="qlistview.html">QListView</a>( this );
|
---|
| 633 |
|
---|
| 634 | pushButton-><a href="#installEventFilter">installEventFilter</a>( keyPressEater );
|
---|
| 635 | listView-><a href="#installEventFilter">installEventFilter</a>( keyPressEater );
|
---|
| 636 | </pre>
|
---|
| 637 |
|
---|
| 638 | <p> The <a href="qaccel.html">QAccel</a> class, for example, uses this technique to intercept
|
---|
| 639 | accelerator key presses.
|
---|
| 640 | <p> <b>Warning:</b> If you delete the receiver object in your <a href="#eventFilter">eventFilter</a>()
|
---|
| 641 | function, be sure to return TRUE. If you return FALSE, Qt sends
|
---|
| 642 | the event to the deleted object and the program will crash.
|
---|
| 643 | <p> <p>See also <a href="#removeEventFilter">removeEventFilter</a>(), <a href="#eventFilter">eventFilter</a>(), and <a href="#event">event</a>().
|
---|
| 644 |
|
---|
| 645 | <h3 class=fn>bool <a name="isA"></a>QObject::isA ( const char * clname ) const
|
---|
| 646 | </h3>
|
---|
| 647 | Returns TRUE if this object is an instance of the class <em>clname</em>;
|
---|
| 648 | otherwise returns FALSE.
|
---|
| 649 | <p> Example:
|
---|
| 650 | <pre>
|
---|
| 651 | <a href="qtimer.html">QTimer</a> *t = new <a href="qtimer.html">QTimer</a>; // QTimer inherits QObject
|
---|
| 652 | t-><a href="#isA">isA</a>( "QTimer" ); // returns TRUE
|
---|
| 653 | t-><a href="#isA">isA</a>( "QObject" ); // returns FALSE
|
---|
| 654 | </pre>
|
---|
| 655 |
|
---|
| 656 | <p> <p>See also <a href="#inherits">inherits</a>() and <a href="#metaObject">metaObject</a>().
|
---|
| 657 |
|
---|
| 658 | <h3 class=fn>bool <a name="isWidgetType"></a>QObject::isWidgetType () const
|
---|
| 659 | </h3>
|
---|
| 660 |
|
---|
| 661 | <p> Returns TRUE if the object is a widget; otherwise returns FALSE.
|
---|
| 662 | <p> Calling this function is equivalent to calling
|
---|
| 663 | <a href="#inherits">inherits</a>("QWidget"), except that it is much faster.
|
---|
| 664 |
|
---|
| 665 | <h3 class=fn>void <a name="killTimer"></a>QObject::killTimer ( int id )
|
---|
| 666 | </h3>
|
---|
| 667 | Kills the timer with timer identifier, <em>id</em>.
|
---|
| 668 | <p> The timer identifier is returned by <a href="#startTimer">startTimer</a>() when a timer
|
---|
| 669 | event is started.
|
---|
| 670 | <p> <p>See also <a href="#timerEvent">timerEvent</a>(), <a href="#startTimer">startTimer</a>(), and <a href="#killTimers">killTimers</a>().
|
---|
| 671 |
|
---|
| 672 | <h3 class=fn>void <a name="killTimers"></a>QObject::killTimers ()
|
---|
| 673 | </h3>
|
---|
| 674 | Kills all timers that this object has started.
|
---|
| 675 | <p> <b>Warning:</b> Using this function can cause hard-to-find bugs: it kills
|
---|
| 676 | timers started by sub- and superclasses as well as those started
|
---|
| 677 | by you, which is often not what you want. We recommend using a
|
---|
| 678 | <a href="qtimer.html">QTimer</a> or perhaps <a href="#killTimer">killTimer</a>().
|
---|
| 679 | <p> <p>See also <a href="#timerEvent">timerEvent</a>(), <a href="#startTimer">startTimer</a>(), and <a href="#killTimer">killTimer</a>().
|
---|
| 680 |
|
---|
| 681 | <h3 class=fn><a href="qmetaobject.html">QMetaObject</a> * <a name="metaObject"></a>QObject::metaObject () const<tt> [virtual]</tt>
|
---|
| 682 | </h3>
|
---|
| 683 |
|
---|
| 684 | <p> Returns a pointer to the <a href="metaobjects.html#meta-object">meta object</a> of this object.
|
---|
| 685 | <p> A meta object contains information about a class that inherits
|
---|
| 686 | QObject, e.g. class name, superclass name, properties, signals and
|
---|
| 687 | slots. Every class that contains the <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> macro will also have
|
---|
| 688 | a meta object.
|
---|
| 689 | <p> The meta object information is required by the signal/slot
|
---|
| 690 | connection mechanism and the property system. The functions <a href="#isA">isA</a>()
|
---|
| 691 | and <a href="#inherits">inherits</a>() also make use of the meta object.
|
---|
| 692 |
|
---|
| 693 | <h3 class=fn>const char * <a name="name"></a>QObject::name () const
|
---|
| 694 | </h3><p>Returns the name of this object.
|
---|
| 695 | See the <a href="qobject.html#name-prop">"name"</a> property for details.
|
---|
| 696 | <h3 class=fn>const char * <a name="name-2"></a>QObject::name ( const char * defaultName ) const
|
---|
| 697 | </h3>
|
---|
| 698 | This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
---|
| 699 | <p> Returns the name of this object, or <em>defaultName</em> if the object
|
---|
| 700 | does not have a name.
|
---|
| 701 |
|
---|
| 702 | <h3 class=fn><a href="qcstring.html">QCString</a> <a name="normalizeSignalSlot"></a>QObject::normalizeSignalSlot ( const char * signalSlot )<tt> [static protected]</tt>
|
---|
| 703 | </h3>
|
---|
| 704 | Normlizes the signal or slot definition <em>signalSlot</em> by removing
|
---|
| 705 | unnecessary whitespace.
|
---|
| 706 |
|
---|
| 707 | <h3 class=fn>const <a href="qobjectlist.html">QObjectList</a> * <a name="objectTrees"></a>QObject::objectTrees ()<tt> [static]</tt>
|
---|
| 708 | </h3>
|
---|
| 709 | Returns a pointer to the list of all object trees (their root
|
---|
| 710 | objects), or 0 if there are no objects.
|
---|
| 711 | <p> The <a href="qobjectlist.html">QObjectList</a> class is defined in the <a href="qobjectlist-h.html">qobjectlist.h</a> header
|
---|
| 712 | file.
|
---|
| 713 | <p> The most recent root object created is the <a href="qptrlist.html#first">first</a> object in the list and the first root object added
|
---|
| 714 | is the <a href="qptrlist.html#last">last</a> object in the list.
|
---|
| 715 | <p> <p>See also <a href="#children">children</a>(), <a href="#parent">parent</a>(), <a href="#insertChild">insertChild</a>(), and <a href="#removeChild">removeChild</a>().
|
---|
| 716 |
|
---|
| 717 | <h3 class=fn><a href="qobject.html">QObject</a> * <a name="parent"></a>QObject::parent () const
|
---|
| 718 | </h3>
|
---|
| 719 |
|
---|
| 720 | <p> Returns a pointer to the parent object.
|
---|
| 721 | <p> <p>See also <a href="#children">children</a>().
|
---|
| 722 |
|
---|
| 723 | <h3 class=fn><a href="qvariant.html">QVariant</a> <a name="property"></a>QObject::property ( const char * name ) const<tt> [virtual]</tt>
|
---|
| 724 | </h3>
|
---|
| 725 | Returns the value of the object's <em>name</em> property.
|
---|
| 726 | <p> If no such property exists, the returned variant is invalid.
|
---|
| 727 | <p> Information about all available properties are provided through
|
---|
| 728 | the <a href="#metaObject">metaObject</a>().
|
---|
| 729 | <p> <p>See also <a href="#setProperty">setProperty</a>(), <a href="qvariant.html#isValid">QVariant::isValid</a>(), <a href="#metaObject">metaObject</a>(), <a href="qmetaobject.html#propertyNames">QMetaObject::propertyNames</a>(), and <a href="qmetaobject.html#property">QMetaObject::property</a>().
|
---|
| 730 |
|
---|
| 731 | <p>Example: <a href="qaxcontainer-example-qutlook.html#x2729">qutlook/centralwidget.cpp</a>.
|
---|
| 732 | <h3 class=fn><a href="qobjectlist.html">QObjectList</a> * <a name="queryList"></a>QObject::queryList ( const char * inheritsClass = 0, const char * objName = 0, bool regexpMatch = TRUE, bool recursiveSearch = TRUE ) const
|
---|
| 733 | </h3>
|
---|
| 734 | Searches the children and optionally grandchildren of this object,
|
---|
| 735 | and returns a list of those objects that are named or that match
|
---|
| 736 | <em>objName</em> and inherit <em>inheritsClass</em>. If <em>inheritsClass</em> is 0
|
---|
| 737 | (the default), all classes match. If <em>objName</em> is 0 (the
|
---|
| 738 | default), all object names match.
|
---|
| 739 | <p> If <em>regexpMatch</em> is TRUE (the default), <em>objName</em> is a <a href="qregexp.html#regular-expression">regular expression</a> that the objects's names must match. The syntax is that
|
---|
| 740 | of a <a href="qregexp.html">QRegExp</a>. If <em>regexpMatch</em> is FALSE, <em>objName</em> is a string
|
---|
| 741 | and object names must match it exactly.
|
---|
| 742 | <p> Note that <em>inheritsClass</em> uses single inheritance from QObject,
|
---|
| 743 | the way <a href="#inherits">inherits</a>() does. According to inherits(), <a href="qmenubar.html">QMenuBar</a>
|
---|
| 744 | inherits <a href="qwidget.html">QWidget</a> but not <a href="qmenudata.html">QMenuData</a>. This does not quite match
|
---|
| 745 | reality, but is the best that can be done on the wide variety of
|
---|
| 746 | compilers Qt supports.
|
---|
| 747 | <p> Finally, if <em>recursiveSearch</em> is TRUE (the default), <a href="#queryList">queryList</a>()
|
---|
| 748 | searches <em>n</em>th-generation as well as first-generation children.
|
---|
| 749 | <p> If all this seems a bit complex for your needs, the simpler
|
---|
| 750 | <a href="#child">child</a>() function may be what you want.
|
---|
| 751 | <p> This somewhat contrived example disables all the buttons in this
|
---|
| 752 | window:
|
---|
| 753 | <pre>
|
---|
| 754 | <a href="qobjectlist.html">QObjectList</a> *l = topLevelWidget()->queryList( "QButton" );
|
---|
| 755 | QObjectListIt it( *l ); // iterate over the buttons
|
---|
| 756 | QObject *obj;
|
---|
| 757 |
|
---|
| 758 | while ( (obj = it.current()) != 0 ) {
|
---|
| 759 | // for each found object...
|
---|
| 760 | ++it;
|
---|
| 761 | ((QButton*)obj)->setEnabled( FALSE );
|
---|
| 762 | }
|
---|
| 763 | delete l; // delete the list, not the objects
|
---|
| 764 | </pre>
|
---|
| 765 |
|
---|
| 766 | <p> The <a href="qobjectlist.html">QObjectList</a> class is defined in the <a href="qobjectlist-h.html">qobjectlist.h</a> header
|
---|
| 767 | file.
|
---|
| 768 | <p> <b>Warning:</b> Delete the list as soon you have finished using it. The
|
---|
| 769 | list contains pointers that may become invalid at almost any time
|
---|
| 770 | without notice (as soon as the user closes a window you may have
|
---|
| 771 | dangling pointers, for example).
|
---|
| 772 | <p> <p>See also <a href="#child">child</a>(), <a href="#children">children</a>(), <a href="#parent">parent</a>(), <a href="#inherits">inherits</a>(), <a href="#name-prop">name</a>, and <a href="qregexp.html">QRegExp</a>.
|
---|
| 773 |
|
---|
| 774 | <h3 class=fn>void <a name="removeChild"></a>QObject::removeChild ( <a href="qobject.html">QObject</a> * obj )<tt> [virtual]</tt>
|
---|
| 775 | </h3>
|
---|
| 776 | Removes the child object <em>obj</em> from the list of children.
|
---|
| 777 | <p> <b>Warning:</b> This function will not remove a child widget from the
|
---|
| 778 | screen. It will only remove it from the parent widget's list of
|
---|
| 779 | children.
|
---|
| 780 | <p> <p>See also <a href="#insertChild">insertChild</a>() and <a href="qwidget.html#reparent">QWidget::reparent</a>().
|
---|
| 781 |
|
---|
| 782 | <h3 class=fn>void <a name="removeEventFilter"></a>QObject::removeEventFilter ( const <a href="qobject.html">QObject</a> * obj )
|
---|
| 783 | </h3>
|
---|
| 784 | Removes an event filter object <em>obj</em> from this object. The
|
---|
| 785 | request is ignored if such an event filter has not been installed.
|
---|
| 786 | <p> All event filters for this object are automatically removed when
|
---|
| 787 | this object is destroyed.
|
---|
| 788 | <p> It is always safe to remove an event filter, even during event
|
---|
| 789 | filter activation (i.e. from the <a href="#eventFilter">eventFilter</a>() function).
|
---|
| 790 | <p> <p>See also <a href="#installEventFilter">installEventFilter</a>(), <a href="#eventFilter">eventFilter</a>(), and <a href="#event">event</a>().
|
---|
| 791 |
|
---|
| 792 | <h3 class=fn>const <a href="qobject.html">QObject</a> * <a name="sender"></a>QObject::sender ()<tt> [protected]</tt>
|
---|
| 793 | </h3>
|
---|
| 794 | Returns a pointer to the object that sent the signal, if called in
|
---|
| 795 | a slot activated by a signal; otherwise it returns 0. The pointer
|
---|
| 796 | is valid only during the execution of the slot that calls this
|
---|
| 797 | function.
|
---|
| 798 | <p> The pointer returned by this function becomes invalid if the
|
---|
| 799 | sender is destroyed, or if the slot is disconnected from the
|
---|
| 800 | sender's signal.
|
---|
| 801 | <p> <b>Warning:</b> This function violates the object-oriented principle of
|
---|
| 802 | modularity. However, getting access to the sender might be useful
|
---|
| 803 | when many signals are connected to a single slot. The sender is
|
---|
| 804 | undefined if the slot is called as a normal C++ function.
|
---|
| 805 |
|
---|
| 806 | <h3 class=fn>void <a name="setName"></a>QObject::setName ( const char * name )<tt> [virtual]</tt>
|
---|
| 807 | </h3>
|
---|
| 808 | Sets the object's name to <em>name</em>.
|
---|
| 809 |
|
---|
| 810 | <h3 class=fn>bool <a name="setProperty"></a>QObject::setProperty ( const char * name, const <a href="qvariant.html">QVariant</a> & value )<tt> [virtual]</tt>
|
---|
| 811 | </h3>
|
---|
| 812 | Sets the value of the object's <em>name</em> property to <em>value</em>.
|
---|
| 813 | <p> Returns TRUE if the operation was successful; otherwise returns
|
---|
| 814 | FALSE.
|
---|
| 815 | <p> Information about all available properties is provided through the
|
---|
| 816 | <a href="#metaObject">metaObject</a>().
|
---|
| 817 | <p> <p>See also <a href="#property">property</a>(), <a href="#metaObject">metaObject</a>(), <a href="qmetaobject.html#propertyNames">QMetaObject::propertyNames</a>(), and <a href="qmetaobject.html#property">QMetaObject::property</a>().
|
---|
| 818 |
|
---|
| 819 | <p>Example: <a href="qaxcontainer-example-qutlook.html#x2730">qutlook/centralwidget.cpp</a>.
|
---|
| 820 | <h3 class=fn>bool <a name="signalsBlocked"></a>QObject::signalsBlocked () const
|
---|
| 821 | </h3>
|
---|
| 822 |
|
---|
| 823 | <p> Returns TRUE if signals are blocked; otherwise returns FALSE.
|
---|
| 824 | <p> Signals are not blocked by default.
|
---|
| 825 | <p> <p>See also <a href="#blockSignals">blockSignals</a>().
|
---|
| 826 |
|
---|
| 827 | <h3 class=fn>int <a name="startTimer"></a>QObject::startTimer ( int interval )
|
---|
| 828 | </h3>
|
---|
| 829 | Starts a timer and returns a timer identifier, or returns zero if
|
---|
| 830 | it could not start a timer.
|
---|
| 831 | <p> A timer event will occur every <em>interval</em> milliseconds until
|
---|
| 832 | <a href="#killTimer">killTimer</a>() or <a href="#killTimers">killTimers</a>() is called. If <em>interval</em> is 0, then
|
---|
| 833 | the timer event occurs once every time there are no more window
|
---|
| 834 | system events to process.
|
---|
| 835 | <p> The virtual <a href="#timerEvent">timerEvent</a>() function is called with the <a href="qtimerevent.html">QTimerEvent</a>
|
---|
| 836 | event parameter class when a timer event occurs. Reimplement this
|
---|
| 837 | function to get timer events.
|
---|
| 838 | <p> If multiple timers are running, the <a href="qtimerevent.html#timerId">QTimerEvent::timerId</a>() can be
|
---|
| 839 | used to find out which timer was activated.
|
---|
| 840 | <p> Example:
|
---|
| 841 | <pre>
|
---|
| 842 | class MyObject : public QObject
|
---|
| 843 | {
|
---|
| 844 | Q_OBJECT
|
---|
| 845 | public:
|
---|
| 846 | MyObject( QObject *parent = 0, const char *name = 0 );
|
---|
| 847 |
|
---|
| 848 | protected:
|
---|
| 849 | void timerEvent( <a href="qtimerevent.html">QTimerEvent</a> * );
|
---|
| 850 | };
|
---|
| 851 |
|
---|
| 852 | MyObject::MyObject( QObject *parent, const char *name )
|
---|
| 853 | : QObject( parent, name )
|
---|
| 854 | {
|
---|
| 855 | <a href="#startTimer">startTimer</a>( 50 ); // 50-millisecond timer
|
---|
| 856 | <a href="#startTimer">startTimer</a>( 1000 ); // 1-second timer
|
---|
| 857 | <a href="#startTimer">startTimer</a>( 60000 ); // 1-minute timer
|
---|
| 858 | }
|
---|
| 859 |
|
---|
| 860 | void MyObject::<a href="#timerEvent">timerEvent</a>( <a href="qtimerevent.html">QTimerEvent</a> *e )
|
---|
| 861 | {
|
---|
| 862 | <a href="qapplication.html#qDebug">qDebug</a>( "timer event, id %d", e-><a href="qtimerevent.html#timerId">timerId</a>() );
|
---|
| 863 | }
|
---|
| 864 | </pre>
|
---|
| 865 |
|
---|
| 866 | <p> Note that <a href="qtimer.html">QTimer</a>'s accuracy depends on the underlying operating
|
---|
| 867 | system and hardware. Most platforms support an accuracy of 20 ms;
|
---|
| 868 | some provide more. If Qt is unable to deliver the requested
|
---|
| 869 | number of timer clicks, it will silently discard some.
|
---|
| 870 | <p> The QTimer class provides a high-level programming interface with
|
---|
| 871 | one-shot timers and timer signals instead of events.
|
---|
| 872 | <p> <p>See also <a href="#timerEvent">timerEvent</a>(), <a href="#killTimer">killTimer</a>(), <a href="#killTimers">killTimers</a>(), <a href="qeventloop.html#awake">QEventLoop::awake</a>(), and <a href="qeventloop.html#aboutToBlock">QEventLoop::aboutToBlock</a>().
|
---|
| 873 |
|
---|
| 874 | <h3 class=fn>void <a name="timerEvent"></a>QObject::timerEvent ( <a href="qtimerevent.html">QTimerEvent</a> * )<tt> [virtual protected]</tt>
|
---|
| 875 | </h3>
|
---|
| 876 | This event handler can be reimplemented in a subclass to receive
|
---|
| 877 | timer events for the object.
|
---|
| 878 | <p> <a href="qtimer.html">QTimer</a> provides a higher-level interface to the timer
|
---|
| 879 | functionality, and also more general information about timers.
|
---|
| 880 | <p> <p>See also <a href="#startTimer">startTimer</a>(), <a href="#killTimer">killTimer</a>(), <a href="#killTimers">killTimers</a>(), and <a href="#event">event</a>().
|
---|
| 881 |
|
---|
| 882 | <p>Examples: <a href="biff-example.html#x1959">biff/biff.cpp</a>, <a href="dclock-example.html#x1102">dclock/dclock.cpp</a>, <a href="forever-example.html#x1048">forever/forever.cpp</a>, <a href="grapher-nsplugin-example.html#x2755">grapher/grapher.cpp</a>, <a href="qmag-example.html#x1781">qmag/qmag.cpp</a>, and <a href="xform-example.html#x1232">xform/xform.cpp</a>.
|
---|
| 883 | <h3 class=fn><a href="qstring.html">QString</a> <a name="tr"></a>QObject::tr ( const char * sourceText, const char * comment )<tt> [static]</tt>
|
---|
| 884 | </h3>
|
---|
| 885 |
|
---|
| 886 |
|
---|
| 887 | <p> Returns a translated version of <em>sourceText</em>, or <em>sourceText</em>
|
---|
| 888 | itself if there is no appropriate translated version. The
|
---|
| 889 | translation context is QObject with <em>comment</em> (0 by default).
|
---|
| 890 | All QObject subclasses using the <a href="metaobjects.html#Q_OBJECT">Q_OBJECT</a> macro automatically have
|
---|
| 891 | a reimplementation of this function with the subclass name as
|
---|
| 892 | context.
|
---|
| 893 | <p> <b>Warning:</b> This method is reentrant only if all translators are
|
---|
| 894 | installed <em>before</em> calling this method. Installing or removing
|
---|
| 895 | translators while performing translations is not supported. Doing
|
---|
| 896 | so will probably result in crashes or other undesirable behavior.
|
---|
| 897 | <p> <p>See also <a href="#trUtf8">trUtf8</a>(), <a href="qapplication.html#translate">QApplication::translate</a>(), and <a href="i18n.html">Internationalization with Qt</a>.
|
---|
| 898 |
|
---|
| 899 | <p>Example: <a href="qdialog.html#x2130">network/networkprotocol/view.cpp</a>.
|
---|
| 900 | <h3 class=fn><a href="qstring.html">QString</a> <a name="trUtf8"></a>QObject::trUtf8 ( const char * sourceText, const char * comment )<tt> [static]</tt>
|
---|
| 901 | </h3>
|
---|
| 902 |
|
---|
| 903 |
|
---|
| 904 | <p> Returns a translated version of <em>sourceText</em>, or
|
---|
| 905 | <a href="qstring.html#fromUtf8">QString::fromUtf8</a>(<em>sourceText</em>) if there is no appropriate
|
---|
| 906 | version. It is otherwise identical to <a href="#tr">tr</a>(<em>sourceText</em>, <em>comment</em>).
|
---|
| 907 | <p> <b>Warning:</b> This method is reentrant only if all translators are
|
---|
| 908 | installed <em>before</em> calling this method. Installing or removing
|
---|
| 909 | translators while performing translations is not supported. Doing
|
---|
| 910 | so will probably result in crashes or other undesirable behavior.
|
---|
| 911 | <p> <p>See also <a href="#tr">tr</a>() and <a href="qapplication.html#translate">QApplication::translate</a>().
|
---|
| 912 |
|
---|
| 913 | <hr><h2>Property Documentation</h2>
|
---|
| 914 | <h3 class=fn><a href="qcstring.html">QCString</a> <a name="name-prop"></a>name</h3>
|
---|
| 915 | <p>This property holds the name of this object.
|
---|
| 916 | <p>You can find an object by name (and type) using <a href="#child">child</a>(). You can
|
---|
| 917 | find a set of objects with <a href="#queryList">queryList</a>().
|
---|
| 918 | <p> The object name is set by the constructor or by the <a href="#setName">setName</a>()
|
---|
| 919 | function. The object name is not very useful in the current
|
---|
| 920 | version of Qt, but will become increasingly important in the
|
---|
| 921 | future.
|
---|
| 922 | <p> If the object does not have a name, the <a href="#name">name</a>() function returns
|
---|
| 923 | "unnamed", so printf() (used in <a href="qapplication.html#qDebug">qDebug</a>()) will not be asked to
|
---|
| 924 | output a null pointer. If you want a null pointer to be returned
|
---|
| 925 | for unnamed objects, you can call name( 0 ).
|
---|
| 926 | <p> <pre>
|
---|
| 927 | <a href="qapplication.html#qDebug">qDebug</a>( "MyClass::setPrecision(): (%s) invalid precision %f",
|
---|
| 928 | <a href="#name">name</a>(), newPrecision );
|
---|
| 929 | </pre>
|
---|
| 930 |
|
---|
| 931 | <p> <p>See also <a href="#className">className</a>(), <a href="#child">child</a>(), and <a href="#queryList">queryList</a>().
|
---|
| 932 |
|
---|
| 933 | <p>Set this property's value with <a href="#setName">setName</a>() and get this property's value with <a href="#name">name</a>().
|
---|
| 934 | <hr><h2>Related Functions</h2>
|
---|
| 935 | <h3 class=fn>void * <a name="qt_find_obj_child"></a>qt_find_obj_child ( <a href="qobject.html">QObject</a> * parent, const char * type, const char * name )
|
---|
| 936 | </h3>
|
---|
| 937 |
|
---|
| 938 | <p> Returns a pointer to the object named <em>name</em> that inherits <em>type</em> and with a given <em>parent</em>.
|
---|
| 939 | <p> Returns 0 if there is no such child.
|
---|
| 940 | <p> <pre>
|
---|
| 941 | <a href="qlistbox.html">QListBox</a> *c = (QListBox *) <a href="#qt_find_obj_child">qt_find_obj_child</a>( myWidget, "QListBox",
|
---|
| 942 | "my list box" );
|
---|
| 943 | if ( c )
|
---|
| 944 | c-><a href="qlistbox.html#insertItem">insertItem</a>( "another string" );
|
---|
| 945 | </pre>
|
---|
| 946 |
|
---|
| 947 |
|
---|
| 948 | <!-- eof -->
|
---|
| 949 | <hr><p>
|
---|
| 950 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 951 | Copyright © 1995-2007
|
---|
| 952 | <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
---|
| 953 | <table width=100% cellspacing=0 border=0><tr>
|
---|
| 954 | <td>Copyright © 2007
|
---|
| 955 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
| 956 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
| 957 | </table></div></address></body>
|
---|
| 958 | </html>
|
---|