The QObject class is the base class of all Qt objects that can deal with signals, slots and events. (details) (complete member list)
#include <qobject.h>
Inherited by QAccel, QSenderObject, QSignal, QTimer and QWidget.
Qt uses a very powerful mechanism, signals that are connected to slots, for communication between objects. An object has zero or more signals and zero or more slots, and a signal may be connected to a slot in any object.
When an object has changed in some way that might be interesting, it emits a signal to tell whoever is interested. If that signal is connected to any slots, those slots get called.
That is. the calling or emitting object doesn't need to know or care what slot the signal is connected to. It works much like the traditional callback mechanism, but it isn't necessary to write null pointer checks or for loops all the time.
QScrollBar is a good example. In order to use it, you create a scroll bar, connect its newValue() signal to a slot which e.g. scrolls your widget. Then, if it suits you, you can connect e.g. QScrollBar::nextLine() to a suitable slot. nextLine() is useless in most cases but if you need it, it's there.
Constructs an object with parent objects parent and a name.
The parent of an object may be viewed as the object's owner. For instance, a dialog box is the parent of the "ok" and "cancel" buttons inside it.
The destructor of a parent object destroys all child objects.
Setting parent to 0 constructs an object with no parent. If the object is a widget, it will become a top-level window.
See also: parent() and name().
Destroys the object and all its children objects.
All signals to and from the object are automatically disconnected.
Blocks signals if block is TRUE, or unblocks signals if block is FALSE.
Emitted signals disappear into hyperspace if signals are blocked.
Returns a list of child objects.
This function is not for the inexperienced.
See also: parent(), insertChild() and removeChild().
Returns the class name of this object.
Warning: This function will return an invalid name if the class constructor did not
call initMetaObject() or if the class definition lacks the Q_OBJECT
macro.
See also: name().
Connects signal from object sender to member in this object.
Disconnects signal from member of receiver.
Disconnects all signals in this object from member of receiver.
To do:
Disconnects signal in object sender from member in object receiver.
If signal is 0, it disconnects receiver and member from any signal.
If member is 0, it disconnects anything that is connected to receiver.
If receiver is 0, it disconnects anything connected to signal.
The sender may not be 0. The member must be 0 if receiver is 0.
Common case I. Disconnect everything connected to an object:
QObject::disconnect( myObject );
Common case II. Disconnect everything connected to a signal:
QObject::disconnect( myObject, SIGNAL(mySignal()) );
Common case III. Disconnect a specific receiver.
QObject::disconnect( myObject, 0, myReceiver, 0 );
See also: connect().
This virtual function receives events to an object and must returns TRUE if the event was recognized and processed.
The event() function can be reimplemented to customize the behavior of an object.
See also: QWidget::event() and installEventFilter(). Reimplemented in QWidget.
Filters events if this object has been installed as an event filter for another object.
The reimplementation of this virtual function must return TRUE if the event should be stopped, or FALSE if the event should be dispatched normally.
See also: installEventFilter().
Returns TRUE if the object is a high priority object, or FALSE if it is a standard priority object.
High priority objects are placed first in list of children, on the assumption that they will be referenced very often.
Currently only QAccel objects are high priority.
Returns TRUE if this object is an instance of a class that inherits clname. (A class is considered to inherit itself.)
QTimer *t = new QTimer; // QTimer inherits QObject
t->inherits("QTimer"); // returns TRUE
t->inherits("QObject"); // returns TRUE
t->inherits("QButton"); // returns FALSE
This function may be used to determine whether a given object
supports certain features. Qt uses it to implement keyboard
accelerators, for instance: A keyboard accelerator is an object for
which inherits("QAccel")
is TRUE.
See also: isA().
Inserts an object obj into the list of child objects.
Warning: This function cannot be used to make a widget a child widget of another. Child widgets can only be created by setting the parent widget in the constructor.
Adds an event filter object for this object.
An event filter is another object that receives all events that are sent to this object via the eventFilter() function. The event filter returns TRUE if the event should be stopped, or FALSE if the event can be dispatched normally.
See also: removeEventFilter(), eventFilter() and event().
Returns TRUE if this object is an instance of a specified class, otherwise FALSE.
QTimer *t = new QTimer; // QTimer inherits QObject
t->isA("QTime"); // returns TRUE
t->isA("QObject"); // returns FALSE
See also: inherits().
Returns TRUE if the object is a widget, or FALSE if not.
Calling this function is equivalent to calling inherits("QWidget"), except that it is much faster.
Kills timer with the identifier id.
The timer identifer is returned by startTimer() when a timer event is started.
See also: startTimer(), killTimers() and QWidget::timerEvent().
Kills all timers that this object has started.
See also: killTimer(), startTimer() and QWidget::timerEvent().
Returns a pointer to the meta object of this object.
A meta object contains information about a class that inherits QObject:
class name, super class name, signals and slots. Every class that contains
the Q_OBJECT
macro will also have a meta object.
The meta object information is required by the signal/slot connection mechanism. The functions isA and inherits() also make use of the meta object.
The meta object is created by the initMetaObject() function, which is generated by the meta object compiler and called from the class constructor.
Warning: If this function returns 0, the constructor probably forgot to call initMetaObject().
Returns the name of this object.
The object name is set by the constructor or the setName() function. The object name is not very useful in the current version of Qt, but it will become increasingly important in the future.
The queryList() function searches the object tree for objects that matches a particular object name.
See also: setName() and className().
Returns a pointer to the parent object.
See also: children().
Returns a list of child objects found by a query.
The query is specified by:
Arguments:
TRUE
(default) if you want to search
the entire object tree, or FALSE
if you want the search to traverse
just the 1st level child objects of this object.
QObjectList *list = myView->queryList( "QButton" ); QObjectListIt it( *list ); // iterate over the buttons QFont newFont( "Courier", 24 ); while ( it.current() ) { it.current()->setFont( newFont ); ++it; } delete list; // delete the search results
The QObjectList class is defined in the qobjcoll.h header file.
Warning: Throw the list away as soon you have finished using it. You can get in serious trouble if you for instance try to access an object that has been deleted.
Returns a list of objects/slot pairs that are connected to the signal, or 0 if nothing is connected to it.
This function is for internal use.
Removes the child object obj from the list of children.
Warning: This function will not remove a child widget from the screen. It will only remove it from the parent widget's list of children.
Removes an event filter object from this object.
See also: installEventFilter(), eventFilter() and event().
Returns a pointer to the object that sent the last signal received by this object.
Sets the name of this object to name.
The object name is not very useful in the current version of Qt, but it will become increasingly important in the future.
The queryList() function searches the object tree for objects that matches a particular object name.
See also: name().
Returns TRUE if signals are blocked, or FALSE if signals are not blocked.
Signals are not blocked by default.
See also: blockSignals().
Starts a timer and returns a timer identifier.
A timer event will occur every interval milliseconds until killTimer() or killTimers() is called. If interval is 0, then timer event occurs as often as possible.
The virtual event() function is called with the QTimerEvent event parameter class when a timer event occurs. Widgets dispatches timer events to the QWidget::timerEvent() event handler. Reimplement this virtual function to get timer events if your object is a widget. If you object is not a widget, you must reimplement the event() function to get timer events.
See also: QTimerEvent, killTimer(), killTimers() and QWidget::timerEvent().
This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.
It was generated from the following files: