1QObject(3qt)                                                      QObject(3qt)
2
3
4

NAME

6       QObject - The base class of all Qt objects
7

SYNOPSIS

9       All the functions in this class are reentrant when Qt is built with
10       thread support.</p>
11
12       #include <qobject.h>
13
14       Inherits Qt.
15
16       Inherited by QAccel, QAccessibleObject, QAction, QApplication,
17       QAssistantClient, QDataPump, QAxObject, QAxScript, QAxScriptManager,
18       QWidget, QCanvas, QStyle, QClipboard, QCopChannel, QDns, QLayout,
19       QDragObject, QEditorFactory, QEventLoop, QFileIconProvider,
20       QNetworkProtocol, QWSKeyboardHandler, QNetworkOperation, QNPInstance,
21       QObjectCleanupHandler, QProcess, QServerSocket, QSessionManager,
22       QSignal, QSignalMapper, QSocket, QSocketNotifier, QSound, QSqlDatabase,
23       QSqlDriver, QSqlForm, QStyleSheet, QTimer, QToolTipGroup, QTranslator,
24       QUrlOperator, and QValidator.
25
26   Public Members
27       QObject ( QObject * parent = 0, const char * name = 0 )
28       virtual ~QObject ()
29       virtual const char * className () const
30       virtual QMetaObject * metaObject () const
31       virtual bool event ( QEvent * e )
32       virtual bool eventFilter ( QObject * watched, QEvent * e )
33       bool isA ( const char * clname ) const
34       bool inherits ( const char * clname ) const
35       const char * name () const
36       const char * name ( const char * defaultName ) const
37       virtual void setName ( const char * name )
38       bool isWidgetType () const
39       bool highPriority () const
40       bool signalsBlocked () const
41       void blockSignals ( bool block )
42       int startTimer ( int interval )
43       void killTimer ( int id )
44       void killTimers ()
45       QObject * child ( const char * objName, const char * inheritsClass = 0,
46           bool recursiveSearch = TRUE )
47       const QObjectList * children () const
48       QObjectList * queryList ( const char * inheritsClass = 0, const char *
49           objName = 0, bool regexpMatch = TRUE, bool recursiveSearch = TRUE )
50           const
51       virtual void insertChild ( QObject * obj )
52       virtual void removeChild ( QObject * obj )
53       void installEventFilter ( const QObject * filterObj )
54       void removeEventFilter ( const QObject * obj )
55       bool connect ( const QObject * sender, const char * signal, const char
56           * member ) const
57       bool disconnect ( const char * signal = 0, const QObject * receiver =
58           0, const char * member = 0 )
59       bool disconnect ( const QObject * receiver, const char * member = 0 )
60       void dumpObjectTree ()
61       void dumpObjectInfo ()
62       virtual bool setProperty ( const char * name, const QVariant & value )
63       virtual QVariant property ( const char * name ) const
64       QObject * parent () const
65
66   Public Slots
67       void deleteLater ()
68
69   Signals
70       void destroyed ()
71       void destroyed ( QObject * obj )
72
73   Static Public Members
74       QString tr ( const char * sourceText, const char * comment )
75       QString trUtf8 ( const char * sourceText, const char * comment )
76       const QObjectList * objectTrees ()
77       bool connect ( const QObject * sender, const char * signal, const
78           QObject * receiver, const char * member )
79       bool disconnect ( const QObject * sender, const char * signal, const
80           QObject * receiver, const char * member )
81
82   Properties
83       QCString name - the name of this object
84
85   Protected Members
86       const QObject * sender ()
87       virtual void timerEvent ( QTimerEvent * )
88       virtual void childEvent ( QChildEvent * )
89       virtual void customEvent ( QCustomEvent * )
90       virtual void connectNotify ( const char * signal )
91       virtual void disconnectNotify ( const char * signal )
92       virtual bool checkConnectArgs ( const char * signal, const QObject *
93           receiver, const char * member )
94
95   Static Protected Members
96       QCString normalizeSignalSlot ( const char * signalSlot )
97
99       void * qt_find_obj_child ( QObject * parent, const char * type, const
100           char * name )
101

DESCRIPTION

103       The QObject class is the base class of all Qt objects.
104
105       QObject is the heart of the Qt object model. The central feature in
106       this model is a very powerful mechanism for seamless object
107       communication called signals and slots. You can connect a signal to a
108       slot with connect() and destroy the connection with disconnect(). To
109       avoid never ending notification loops you can temporarily block signals
110       with blockSignals(). The protected functions connectNotify() and
111       disconnectNotify() make it possible to track connections.
112
113       QObjects organize themselves in object trees. When you create a QObject
114       with another object as parent, the object will automatically do an
115       insertChild() on the parent and thus show up in the parent's children()
116       list. The parent takes ownership of the object i.e. it will
117       automatically delete its children in its destructor. You can look for
118       an object by name and optionally type using child() or queryList(), and
119       get the list of tree roots using objectTrees().
120
121       Every object has an object name() and can report its className() and
122       whether it inherits() another class in the QObject inheritance
123       hierarchy.
124
125       When an object is deleted, it emits a destroyed() signal. You can catch
126       this signal to avoid dangling references to QObjects. The QGuardedPtr
127       class provides an elegant way to use this feature.
128
129       QObjects can receive events through event() and filter the events of
130       other objects. See installEventFilter() and eventFilter() for details.
131       A convenience handler, childEvent(), can be reimplemented to catch
132       child events.
133
134       Last but not least, QObject provides the basic timer support in Qt; see
135       QTimer for high-level support for timers.
136
137       Notice that the Q_OBJECT macro is mandatory for any object that
138       implements signals, slots or properties. You also need to run the moc
139       program (Meta Object Compiler) on the source file. We strongly
140       recommend the use of this macro in all subclasses of QObject regardless
141       of whether or not they actually use signals, slots and properties,
142       since failure to do so may lead certain functions to exhibit undefined
143       behaviour.
144
145       All Qt widgets inherit QObject. The convenience function isWidgetType()
146       returns whether an object is actually a widget. It is much faster than
147       inherits( "QWidget" ).
148
149       Some QObject functions, e.g. children(), objectTrees() and queryList()
150       return a QObjectList. A QObjectList is a QPtrList of QObjects.
151       QObjectLists support the same operations as QPtrLists and have an
152       iterator class, QObjectListIt.
153
154       See also Object Model.
155

MEMBER FUNCTION DOCUMENTATION

QObject::QObject ( QObject * parent = 0, const char * name = 0 )

158       Constructs an object called name with parent object, parent.
159
160       The parent of an object may be viewed as the object's owner. For
161       instance, a dialog box is the parent of the" OK" and "Cancel" buttons
162       it contains.
163
164       The destructor of a parent object destroys all child objects.
165
166       Setting parent to 0 constructs an object with no parent. If the object
167       is a widget, it will become a top-level window.
168
169       The object name is some text that can be used to identify a QObject.
170       It's particularly useful in conjunction with Qt Designer. You can find
171       an object by name (and type) using child(). To find several objects use
172       queryList().
173
174       See also parent(), name, child(), and queryList().
175

QObject::~QObject () [virtual]

177       Destroys the object, deleting all its child objects.
178
179       All signals to and from the object are automatically disconnected.
180
181       Warning: All child objects are deleted. If any of these objects are on
182       the stack or global, sooner or later your program will crash. We do not
183       recommend holding pointers to child objects from outside the parent. If
184       you still do, the QObject::destroyed() signal gives you an opportunity
185       to detect when an object is destroyed.
186
187       Warning: Deleting a QObject while pending events are waiting to be
188       delivered can cause a crash. You must not delete the QObject directly
189       from a thread that is not the GUI thread. Use the
190       QObject::deleteLater() method instead, which will cause the event loop
191       to delete the object after all pending events have been delivered to
192       the object.
193

void QObject::blockSignals ( bool block )

195       Blocks signals if block is TRUE, or unblocks signals if block is FALSE.
196
197       Emitted signals disappear into hyperspace if signals are blocked. Note
198       that the destroyed() signals will be emitted even if the signals for
199       this object have been blocked.
200
201       Examples:
202

bool QObject::checkConnectArgs ( const char * signal, const QObject *

204       receiver, const char * member ) [virtual protected]
205       Returns TRUE if the signal and the member arguments are compatible;
206       otherwise returns FALSE. (The receiver argument is currently ignored.)
207
208       Warning: We recommend that you use the default implementation and do
209       not reimplement this function.
210

QObject * QObject::child ( const char * objName, const char * inheritsClass =

212       0, bool recursiveSearch = TRUE )
213       Searches the children and optionally grandchildren of this object, and
214       returns a child that is called objName that inherits inheritsClass. If
215       inheritsClass is 0 (the default), any class matches.
216
217       If recursiveSearch is TRUE (the default), child() performs a depth-
218       first search of the object's children.
219
220       If there is no such object, this function returns 0. If there are more
221       than one, the first one found is retured; if you need all of them, use
222       queryList().
223

void QObject::childEvent ( QChildEvent * ) [virtual protected]

225       This event handler can be reimplemented in a subclass to receive child
226       events.
227
228       Child events are sent to objects when children are inserted or removed.
229
230       Note that events with QEvent::type() QEvent::ChildInserted are posted
231       (with QApplication::postEvent()) to make sure that the child's
232       construction is completed before this function is called.
233
234       If a child is removed immediately after it is inserted, the
235       ChildInserted event may be suppressed, but the ChildRemoved event will
236       always be sent. In such cases it is possible that there will be a
237       ChildRemoved event without a corresponding ChildInserted event.
238
239       If you change state based on ChildInserted events, call
240       QWidget::constPolish(), or do
241
242               QApplication::sendPostedEvents( this, QEvent::ChildInserted );
243       in functions that depend on the state. One notable example is
244       QWidget::sizeHint().
245
246       See also event() and QChildEvent.
247
248       Reimplemented in QMainWindow and QSplitter.
249

const QObjectList * QObject::children () const

251       Returns a list of child objects, or 0 if this object has no children.
252
253       The QObjectList class is defined in the qobjectlist.h header file.
254
255       The first child added is the first object in the list and the last
256       child added is the last object in the list, i.e. new children are
257       appended at the end.
258
259       Note that the list order changes when QWidget children are raised or
260       lowered. A widget that is raised becomes the last object in the list,
261       and a widget that is lowered becomes the first object in the list.
262
263       See also child(), queryList(), parent(), insertChild(), and
264       removeChild().
265

const char * QObject::className () const [virtual]

267       Returns the class name of this object.
268
269       This function is generated by the Meta Object Compiler.
270
271       Warning: This function will return the wrong name if the class
272       definition lacks the Q_OBJECT macro.
273
274       See also name, inherits(), isA(), and isWidgetType().
275
276       Example: sql/overview/custom1/main.cpp.
277

bool QObject::connect ( const QObject * sender, const char * signal, const

279       QObject * receiver, const char * member ) [static]
280       Connects signal from the sender object to member in object receiver,
281       and returns TRUE if the connection succeeds; otherwise returns FALSE.
282
283       You must use the SIGNAL() and SLOT() macros when specifying the signal
284       and the member, for example:
285
286           QLabel     *label  = new QLabel;
287           QScrollBar *scroll = new QScrollBar;
288           QObject::connect( scroll, SIGNAL(valueChanged(int)),
289                             label,  SLOT(setNum(int)) );
290
291       This example ensures that the label always displays the current scroll
292       bar value. Note that the signal and slots parameters must not contain
293       any variable names, only the type. E.g. the following would not work
294       and return FALSE: QObject::connect( scroll, SIGNAL(valueChanged(int
295       v)), label, SLOT(setNum(int v)) );
296
297       A signal can also be connected to another signal:
298
299           class MyWidget : public QWidget
300           {
301               Q_OBJECT
302           public:
303               MyWidget();
304           signals:
305               void myUsefulSignal();
306           private:
307               QPushButton *aButton;
308           };
309           MyWidget::MyWidget()
310           {
311               aButton = new QPushButton( this );
312               connect( aButton, SIGNAL(clicked()), SIGNAL(myUsefulSignal()) );
313           }
314
315       In this example, the MyWidget constructor relays a signal from a
316       private member variable, and makes it available under a name that
317       relates to MyWidget.
318
319       A signal can be connected to many slots and signals. Many signals can
320       be connected to one slot.
321
322       If a signal is connected to several slots, the slots are activated in
323       an arbitrary order when the signal is emitted.
324
325       The function returns TRUE if it successfully connects the signal to the
326       slot. It will return FALSE if it cannot create the connection, for
327       example, if QObject is unable to verify the existence of either signal
328       or member, or if their signatures aren't compatible.
329
330       A signal is emitted for every connection you make, so if you duplicate
331       a connection, two signals will be emitted. You can always break a
332       connection using disconnect().
333
334       See also disconnect().
335
336       Examples:
337

bool QObject::connect ( const QObject * sender, const char * signal, const

339       char * member ) const
340       This is an overloaded member function, provided for convenience. It
341       behaves essentially like the above function.
342
343       Connects signal from the sender object to this object's member.
344
345       Equivalent to: QObject::connect(sender, signal, this, member).
346
347       See also disconnect().
348

void QObject::connectNotify ( const char * signal ) [virtual protected]

350       This virtual function is called when something has been connected to
351       signal in this object.
352
353       Warning: This function violates the object-oriented principle of
354       modularity. However, it might be useful when you need to perform
355       expensive initialization only if something is connected to a signal.
356
357       See also connect() and disconnectNotify().
358

void QObject::customEvent ( QCustomEvent * ) [virtual protected]

360       This event handler can be reimplemented in a subclass to receive custom
361       events. Custom events are user-defined events with a type value at
362       least as large as the "User" item of the QEvent::Type enum, and is
363       typically a QCustomEvent or QCustomEvent subclass.
364
365       See also event() and QCustomEvent.
366

void QObject::deleteLater () [slot]

368       Performs a deferred deletion of this object.
369
370       Instead of an immediate deletion this function schedules a deferred
371       delete event for processing when Qt returns to the main event loop.
372
373       Example: table/bigtable/main.cpp.
374

void QObject::destroyed () [signal]

376       This signal is emitted when the object is being destroyed.
377
378       Note that the signal is emitted by the QObject destructor, so the
379       object's virtual table is already degenerated at this point, and it is
380       not safe to call any functions on the object emitting the signal. This
381       signal can not be blocked.
382
383       All the objects's children are destroyed immediately after this signal
384       is emitted.
385

void QObject::destroyed ( QObject * obj ) [signal]

387       This is an overloaded member function, provided for convenience. It
388       behaves essentially like the above function.
389
390       This signal is emitted immediately before the object obj is destroyed,
391       and can not be blocked.
392
393       All the objects's children are destroyed immediately after this signal
394       is emitted.
395

bool QObject::disconnect ( const QObject * sender, const char * signal, const

397       QObject * receiver, const char * member ) [static]
398       Disconnects signal in object sender from member in object receiver.
399
400       A signal-slot connection is removed when either of the objects involved
401       are destroyed.
402
403       disconnect() is typically used in three ways, as the following examples
404       demonstrate. <ol type=1>
405
406       1      Disconnect everything connected to an object's signals:
407
408                     disconnect( myObject, 0, 0, 0 );
409              equivalent to the non-static overloaded function
410
411                     myObject->disconnect();
412
413       2      Disconnect everything connected to a specific signal:
414
415                     disconnect( myObject, SIGNAL(mySignal()), 0, 0 );
416              equivalent to the non-static overloaded function
417
418                     myObject->disconnect( SIGNAL(mySignal()) );
419
420       3      Disconnect a specific receiver:
421
422                     disconnect( myObject, 0, myReceiver, 0 );
423              equivalent to the non-static overloaded function
424
425                     myObject->disconnect(  myReceiver );
426
427       0 may be used as a wildcard, meaning "any signal", "any receiving
428       object", or "any slot in the receiving object", respectively.
429
430       The sender may never be 0. (You cannot disconnect signals from more
431       than one object in a single call.)
432
433       If signal is 0, it disconnects receiver and member from any signal. If
434       not, only the specified signal is disconnected.
435
436       If receiver is 0, it disconnects anything connected to signal. If not,
437       slots in objects other than receiver are not disconnected.
438
439       If member is 0, it disconnects anything that is connected to receiver.
440       If not, only slots named member will be disconnected, and all other
441       slots are left alone. The member must be 0 if receiver is left out, so
442       you cannot disconnect a specifically-named slot on all objects.
443
444       See also connect().
445

bool QObject::disconnect ( const char * signal = 0, const QObject * receiver =

447       0, const char * member = 0 )
448       This is an overloaded member function, provided for convenience. It
449       behaves essentially like the above function.
450
451       Disconnects signal from member of receiver.
452
453       A signal-slot connection is removed when either of the objects involved
454       are destroyed.
455

bool QObject::disconnect ( const QObject * receiver, const char * member = 0 )

457
458       This is an overloaded member function, provided for convenience. It
459       behaves essentially like the above function.
460
461       Disconnects all signals in this object from receiver's member.
462
463       A signal-slot connection is removed when either of the objects involved
464       are destroyed.
465

void QObject::disconnectNotify ( const char * signal ) [virtual protected]

467       This virtual function is called when something has been disconnected
468       from signal in this object.
469
470       Warning: This function violates the object-oriented principle of
471       modularity. However, it might be useful for optimizing access to
472       expensive resources.
473
474       See also disconnect() and connectNotify().
475

void QObject::dumpObjectInfo ()

477       Dumps information about signal connections, etc. for this object to the
478       debug output.
479
480       This function is useful for debugging, but does nothing if the library
481       has been compiled in release mode (i.e. without debugging information).
482

void QObject::dumpObjectTree ()

484       Dumps a tree of children to the debug output.
485
486       This function is useful for debugging, but does nothing if the library
487       has been compiled in release mode (i.e. without debugging information).
488

bool QObject::event ( QEvent * e ) [virtual]

490       This virtual function receives events to an object and should return
491       TRUE if the event e was recognized and processed.
492
493       The event() function can be reimplemented to customize the behavior of
494       an object.
495
496       See also installEventFilter(), timerEvent(), QApplication::sendEvent(),
497       QApplication::postEvent(), and QWidget::event().
498
499       Reimplemented in QWidget.
500

bool QObject::eventFilter ( QObject * watched, QEvent * e ) [virtual]

502       Filters events if this object has been installed as an event filter for
503       the watched object.
504
505       In your reimplementation of this function, if you want to filter the
506       event e, out, i.e. stop it being handled further, return TRUE;
507       otherwise return FALSE.
508
509       Example:
510
511           class MyMainWindow : public QMainWindow
512           {
513           public:
514               MyMainWindow( QWidget *parent = 0, const char *name = 0 );
515           protected:
516               bool eventFilter( QObject *obj, QEvent *ev );
517           private:
518               QTextEdit *textEdit;
519           };
520           MyMainWindow::MyMainWindow( QWidget *parent, const char *name )
521               : QMainWindow( parent, name )
522           {
523               textEdit = new QTextEdit( this );
524               setCentralWidget( textEdit );
525               textEdit->installEventFilter( this );
526           }
527           bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev )
528           {
529               if ( obj == textEdit ) {
530                   if ( e->type() == QEvent::KeyPress ) {
531                       QKeyEvent *k = (QKeyEvent*)ev;
532                       qDebug( "Ate key press %d", k->key() );
533                       return TRUE;
534                   } else {
535                       return FALSE;
536                   }
537               } else {
538                   // pass the event on to the parent class
539                   return QMainWindow::eventFilter( obj, ev );
540               }
541           }
542
543       Notice in the example above that unhandled events are passed to the
544       base class's eventFilter() function, since the base class might have
545       reimplemented eventFilter() for its own internal purposes.
546
547       Warning: If you delete the receiver object in this function, be sure to
548       return TRUE. Otherwise, Qt will forward the event to the deleted object
549       and the program might crash.
550
551       See also installEventFilter().
552
553       Reimplemented in QAccel, QScrollView, and QSpinBox.
554

bool QObject::highPriority () const

556       Returns TRUE if the object is a high-priority object, or FALSE if it is
557       a standard-priority object.
558
559       High-priority objects are placed first in QObject's list of children on
560       the assumption that they will be referenced very often.
561

bool QObject::inherits ( const char * clname ) const

563       Returns TRUE if this object is an instance of a class that inherits
564       clname, and clname inherits QObject; otherwise returns FALSE.
565
566       A class is considered to inherit itself.
567
568       Example:
569
570               QTimer *t = new QTimer;         // QTimer inherits QObject
571               t->inherits( "QTimer" );        // returns TRUE
572               t->inherits( "QObject" );       // returns TRUE
573               t->inherits( "QButton" );       // returns FALSE
574               // QScrollBar inherits QWidget and QRangeControl
575               QScrollBar *s = new QScrollBar( 0 );
576               s->inherits( "QWidget" );       // returns TRUE
577               s->inherits( "QRangeControl" ); // returns FALSE
578
579       (QRangeControl is not a QObject.)
580
581       See also isA() and metaObject().
582
583       Examples:
584

void QObject::insertChild ( QObject * obj ) [virtual]

586       Inserts an object obj into the list of child objects.
587
588       Warning: This function cannot be used to make one widget the child
589       widget of another widget. Child widgets can only be created by setting
590       the parent widget in the constructor or by calling QWidget::reparent().
591
592       See also removeChild() and QWidget::reparent().
593

void QObject::installEventFilter ( const QObject * filterObj )

595       Installs an event filter filterObj on this object. For example:
596
597           monitoredObj->installEventFilter( filterObj );
598
599       An event filter is an object that receives all events that are sent to
600       this object. The filter can either stop the event or forward it to this
601       object. The event filter filterObj receives events via its
602       eventFilter() function. The eventFilter() function must return TRUE if
603       the event should be filtered, (i.e. stopped); otherwise it must return
604       FALSE.
605
606       If multiple event filters are installed on a single object, the filter
607       that was installed last is activated first.
608
609       Here's a KeyPressEater class that eats the key presses of its monitored
610       objects:
611
612           class KeyPressEater : public QObject
613           {
614               ...
615           protected:
616               bool eventFilter( QObject *o, QEvent *e );
617           };
618           bool KeyPressEater::eventFilter( QObject *o, QEvent *e )
619           {
620               if ( e->type() == QEvent::KeyPress ) {
621                   // special processing for key press
622                   QKeyEvent *k = (QKeyEvent *)e;
623                   qDebug( "Ate key press %d", k->key() );
624                   return TRUE; // eat event
625               } else {
626                   // standard event processing
627                   return FALSE;
628               }
629           }
630
631       And here's how to install it on two widgets:
632
633               KeyPressEater *keyPressEater = new KeyPressEater( this );
634               QPushButton *pushButton = new QPushButton( this );
635               QListView *listView = new QListView( this );
636               pushButton->installEventFilter( keyPressEater );
637               listView->installEventFilter( keyPressEater );
638
639       The QAccel class, for example, uses this technique to intercept
640       accelerator key presses.
641
642       Warning: If you delete the receiver object in your eventFilter()
643       function, be sure to return TRUE. If you return FALSE, Qt sends the
644       event to the deleted object and the program will crash.
645
646       See also removeEventFilter(), eventFilter(), and event().
647

bool QObject::isA ( const char * clname ) const

649       Returns TRUE if this object is an instance of the class clname;
650       otherwise returns FALSE.
651
652       Example:
653
654           QTimer *t = new QTimer; // QTimer inherits QObject
655           t->isA( "QTimer" );     // returns TRUE
656           t->isA( "QObject" );    // returns FALSE
657
658       See also inherits() and metaObject().
659

bool QObject::isWidgetType () const

661       Returns TRUE if the object is a widget; otherwise returns FALSE.
662
663       Calling this function is equivalent to calling inherits("QWidget"),
664       except that it is much faster.
665

void QObject::killTimer ( int id )

667       Kills the timer with timer identifier, id.
668
669       The timer identifier is returned by startTimer() when a timer event is
670       started.
671
672       See also timerEvent(), startTimer(), and killTimers().
673

void QObject::killTimers ()

675       Kills all timers that this object has started.
676
677       Warning: Using this function can cause hard-to-find bugs: it kills
678       timers started by sub- and superclasses as well as those started by
679       you, which is often not what you want. We recommend using a QTimer or
680       perhaps killTimer().
681
682       See also timerEvent(), startTimer(), and killTimer().
683

QMetaObject * QObject::metaObject () const [virtual]

685       Returns a pointer to the meta object of this object.
686
687       A meta object contains information about a class that inherits QObject,
688       e.g. class name, superclass name, properties, signals and slots. Every
689       class that contains the Q_OBJECT macro will also have a meta object.
690
691       The meta object information is required by the signal/slot connection
692       mechanism and the property system. The functions isA() and inherits()
693       also make use of the meta object.
694

const char * QObject::name () const

696       Returns the name of this object. See the "name" property for details.
697

const char * QObject::name ( const char * defaultName ) const

699       This is an overloaded member function, provided for convenience. It
700       behaves essentially like the above function.
701
702       Returns the name of this object, or defaultName if the object does not
703       have a name.
704

QCString QObject::normalizeSignalSlot ( const char * signalSlot ) [static

706       protected]
707       Normlizes the signal or slot definition signalSlot by removing
708       unnecessary whitespace.
709

const QObjectList * QObject::objectTrees () [static]

711       Returns a pointer to the list of all object trees (their root objects),
712       or 0 if there are no objects.
713
714       The QObjectList class is defined in the qobjectlist.h header file.
715
716       The most recent root object created is the first object in the list and
717       the first root object added is the last object in the list.
718
719       See also children(), parent(), insertChild(), and removeChild().
720

QObject * QObject::parent () const

722       Returns a pointer to the parent object.
723
724       See also children().
725

QVariant QObject::property ( const char * name ) const [virtual]

727       Returns the value of the object's name property.
728
729       If no such property exists, the returned variant is invalid.
730
731       Information about all available properties are provided through the
732       metaObject().
733
734       See also setProperty(), QVariant::isValid(), metaObject(),
735       QMetaObject::propertyNames(), and QMetaObject::property().
736
737       Example: qutlook/centralwidget.cpp.
738

QObjectList * QObject::queryList ( const char * inheritsClass = 0, const char

740       * objName = 0, bool regexpMatch = TRUE, bool recursiveSearch = TRUE )
741       const
742       Searches the children and optionally grandchildren of this object, and
743       returns a list of those objects that are named or that match objName
744       and inherit inheritsClass. If inheritsClass is 0 (the default), all
745       classes match. If objName is 0 (the default), all object names match.
746
747       If regexpMatch is TRUE (the default), objName is a regular expression
748       that the objects's names must match. The syntax is that of a QRegExp.
749       If regexpMatch is FALSE, objName is a string and object names must
750       match it exactly.
751
752       Note that inheritsClass uses single inheritance from QObject, the way
753       inherits() does. According to inherits(), QMenuBar inherits QWidget but
754       not QMenuData. This does not quite match reality, but is the best that
755       can be done on the wide variety of compilers Qt supports.
756
757       Finally, if recursiveSearch is TRUE (the default), queryList() searches
758       nth-generation as well as first-generation children.
759
760       If all this seems a bit complex for your needs, the simpler child()
761       function may be what you want.
762
763       This somewhat contrived example disables all the buttons in this
764       window:
765
766           QObjectList *l = topLevelWidget()->queryList( "QButton" );
767           QObjectListIt it( *l ); // iterate over the buttons
768           QObject *obj;
769           while ( (obj = it.current()) != 0 ) {
770               // for each found object...
771               ++it;
772               ((QButton*)obj)->setEnabled( FALSE );
773           }
774           delete l; // delete the list, not the objects
775
776       The QObjectList class is defined in the qobjectlist.h header file.
777
778       Warning: Delete the list as soon you have finished using it. The list
779       contains pointers that may become invalid at almost any time without
780       notice (as soon as the user closes a window you may have dangling
781       pointers, for example).
782
783       See also child(), children(), parent(), inherits(), name, and QRegExp.
784

void QObject::removeChild ( QObject * obj ) [virtual]

786       Removes the child object obj from the list of children.
787
788       Warning: This function will not remove a child widget from the screen.
789       It will only remove it from the parent widget's list of children.
790
791       See also insertChild() and QWidget::reparent().
792

void QObject::removeEventFilter ( const QObject * obj )

794       Removes an event filter object obj from this object. The request is
795       ignored if such an event filter has not been installed.
796
797       All event filters for this object are automatically removed when this
798       object is destroyed.
799
800       It is always safe to remove an event filter, even during event filter
801       activation (i.e. from the eventFilter() function).
802
803       See also installEventFilter(), eventFilter(), and event().
804

const QObject * QObject::sender () [protected]

806       Returns a pointer to the object that sent the signal, if called in a
807       slot activated by a signal; otherwise it returns 0. The pointer is
808       valid only during the execution of the slot that calls this function.
809
810       The pointer returned by this function becomes invalid if the sender is
811       destroyed, or if the slot is disconnected from the sender's signal.
812
813       Warning: This function violates the object-oriented principle of
814       modularity. However, getting access to the sender might be useful when
815       many signals are connected to a single slot. The sender is undefined if
816       the slot is called as a normal C++ function.
817

void QObject::setName ( const char * name ) [virtual]

819       Sets the object's name to name.
820

bool QObject::setProperty ( const char * name, const QVariant & value )

822       [virtual]
823       Sets the value of the object's name property to value.
824
825       Returns TRUE if the operation was successful; otherwise returns FALSE.
826
827       Information about all available properties is provided through the
828       metaObject().
829
830       See also property(), metaObject(), QMetaObject::propertyNames(), and
831       QMetaObject::property().
832
833       Example: qutlook/centralwidget.cpp.
834

bool QObject::signalsBlocked () const

836       Returns TRUE if signals are blocked; otherwise returns FALSE.
837
838       Signals are not blocked by default.
839
840       See also blockSignals().
841

int QObject::startTimer ( int interval )

843       Starts a timer and returns a timer identifier, or returns zero if it
844       could not start a timer.
845
846       A timer event will occur every interval milliseconds until killTimer()
847       or killTimers() is called. If interval is 0, then the timer event
848       occurs once every time there are no more window system events to
849       process.
850
851       The virtual timerEvent() function is called with the QTimerEvent event
852       parameter class when a timer event occurs. Reimplement this function to
853       get timer events.
854
855       If multiple timers are running, the QTimerEvent::timerId() can be used
856       to find out which timer was activated.
857
858       Example:
859
860           class MyObject : public QObject
861           {
862               Q_OBJECT
863           public:
864               MyObject( QObject *parent = 0, const char *name = 0 );
865           protected:
866               void timerEvent( QTimerEvent * );
867           };
868           MyObject::MyObject( QObject *parent, const char *name )
869               : QObject( parent, name )
870           {
871               startTimer( 50 );    // 50-millisecond timer
872               startTimer( 1000 );  // 1-second timer
873               startTimer( 60000 ); // 1-minute timer
874           }
875           void MyObject::timerEvent( QTimerEvent *e )
876           {
877               qDebug( "timer event, id %d", e->timerId() );
878           }
879
880       Note that QTimer's accuracy depends on the underlying operating system
881       and hardware. Most platforms support an accuracy of 20 ms; some provide
882       more. If Qt is unable to deliver the requested number of timer clicks,
883       it will silently discard some.
884
885       The QTimer class provides a high-level programming interface with one-
886       shot timers and timer signals instead of events.
887
888       See also timerEvent(), killTimer(), killTimers(), QEventLoop::awake(),
889       and QEventLoop::aboutToBlock().
890

void QObject::timerEvent ( QTimerEvent * ) [virtual protected]

892       This event handler can be reimplemented in a subclass to receive timer
893       events for the object.
894
895       QTimer provides a higher-level interface to the timer functionality,
896       and also more general information about timers.
897
898       See also startTimer(), killTimer(), killTimers(), and event().
899
900       Examples:
901

QString QObject::tr ( const char * sourceText, const char * comment ) [static]

903
904       Returns a translated version of sourceText, or sourceText itself if
905       there is no appropriate translated version. The translation context is
906       QObject with comment (0 by default). All QObject subclasses using the
907       Q_OBJECT macro automatically have a reimplementation of this function
908       with the subclass name as context.
909
910       Warning: This method is reentrant only if all translators are installed
911       before calling this method. Installing or removing translators while
912       performing translations is not supported. Doing so will probably result
913       in crashes or other undesirable behavior.
914
915       See also trUtf8(), QApplication::translate(), and Internationalization
916       with Qt.
917
918       Example: network/networkprotocol/view.cpp.
919

QString QObject::trUtf8 ( const char * sourceText, const char * comment )

921       [static]
922       Returns a translated version of sourceText, or
923       QString::fromUtf8(sourceText) if there is no appropriate version. It is
924       otherwise identical to tr(sourceText, comment).
925
926       Warning: This method is reentrant only if all translators are installed
927       before calling this method. Installing or removing translators while
928       performing translations is not supported. Doing so will probably result
929       in crashes or other undesirable behavior.
930
931       See also tr() and QApplication::translate().
932
933   Property Documentation

QCString name

935       This property holds the name of this object.
936
937       You can find an object by name (and type) using child(). You can find a
938       set of objects with queryList().
939
940       The object name is set by the constructor or by the setName() function.
941       The object name is not very useful in the current version of Qt, but
942       will become increasingly important in the future.
943
944       If the object does not have a name, the name() function returns"
945       unnamed", so printf() (used in qDebug()) will not be asked to output a
946       null pointer. If you want a null pointer to be returned for unnamed
947       objects, you can call name( 0 ).
948
949               qDebug( "MyClass::setPrecision(): (%s) invalid precision %f",
950                       name(), newPrecision );
951
952       See also className(), child(), and queryList().
953
954       Set this property's value with setName() and get this property's value
955       with name().
956

void * qt_find_obj_child ( QObject * parent, const char * type, const char *

959       name )
960       Returns a pointer to the object named name that inherits type and with
961       a given parent.
962
963       Returns 0 if there is no such child.
964
965               QListBox *c = (QListBox *) qt_find_obj_child( myWidget, "QListBox",
966                                                             "my list box" );
967               if ( c )
968                   c->insertItem( "another string" );
969
970

SEE ALSO

972       http://doc.trolltech.com/qobject.html
973       http://www.trolltech.com/faq/tech.html
974
976       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
977       license file included in the distribution for a complete license
978       statement.
979

AUTHOR

981       Generated automatically from the source code.
982

BUGS

984       If you find a bug in Qt, please report it as described in
985       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
986       help you. Thank you.
987
988       The definitive Qt documentation is provided in HTML format; it is
989       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
990       web browser. This man page is provided as a convenience for those users
991       who prefer man pages, although this format is not officially supported
992       by Trolltech.
993
994       If you find errors in this manual page, please report them to qt-
995       bugs@trolltech.com.  Please include the name of the manual page
996       (qobject.3qt) and the Qt version (3.3.8).
997
998
999
1000Trolltech AS                    2 February 2007                   QObject(3qt)
Impressum