QObject - The base class of all Qt objects
#include <qobject.h>
Inherits Qt.
Inherited by QAccel, QAction, QApplication, QAuServer,
QCanvas, QClipboard, QCopChannel, QDataPump, QDns,
QDnsSocket, QDragManager, QDragObject, QFileIconProvider,
QGuardedPtrPrivate, QLayout, QNPInstance,
QNetworkOperation, QNetworkProtocol, QSenderObject,
QServerSocket, QSessionManager, QSignal, QSignalMapper,
QSocket, QSocketNotifier, QSound, QStyle, QStyleSheet,
QTimer, QToolTipGroup, QTranslator, QUrlOperator,
QValidator, QWSClient, QWSKeyboardHandler,
QWSMouseHandler, QWSServer and QWidget.
Public Members
QObject ( QObject * parent=0, const char * name=0 )
virtual ~QObject ()
virtual bool event ( QEvent * )
virtual bool eventFilter ( QObject *, QEvent * )
virtual QMetaObject* metaObject () const
virtual const char* className () const
bool isA ( const char * ) const
bool inherits ( const char * ) const
const char* name () const
const char* name ( const char * defaultName ) const
virtual void setName ( const char * name )
bool isWidgetType () const
bool highPriority () const
bool signalsBlocked () const
void blockSignals ( bool b )
int startTimer ( int interval )
void killTimer ( int id )
void killTimers ()
QObject* child ( const char * name, const char * type = 0
)
const QObjectList* children () const
QObjectList* queryList ( const char * inheritsClass = 0,
const char * objName = 0, bool regexpMatch = TRUE,
bool recursiveSearch = TRUE )
virtual void insertChild ( QObject * )
virtual void removeChild ( QObject * )
void installEventFilter ( const QObject * )
void removeEventFilter ( const QObject * )
bool connect ( const QObject * sender, const char *
signal, const char * member ) const
bool disconnect ( const char * signal=0, const QObject *
receiver=0, const char * member=0 )
bool disconnect ( const QObject * receiver, const char *
member=0 )
void dumpObjectInfo ()
bool setProperty ( const char * name, const QVariant &
value )
QVariant property ( const char * name ) const
QObject* parent () const
QStringList superClasses ( bool includeThis = FALSE )
const (obsolete)
Signals
void destroyed ()
Static Public Members
QString tr ( const char * )
QString tr ( const char *, const char * )
const QObjectList* objectTrees ()
bool connect ( const QObject * sender, const char *
signal, const QObject * receiver, const char * member
)
bool disconnect ( const QObject * sender, const char *
signal, const QObject * receiver, const char * member
)
Protected Members
bool activate_filters ( QEvent * ) (internal)
QConnectionList* receivers ( const char * signal ) const
void activate_signal ( const char * signal ) (internal)
void activate_signal ( const char * signal, short )
void activate_signal ( const char * signal, int )
void activate_signal ( const char * signal, long )
void activate_signal ( const char * signal, const char * )
void activate_signal_bool ( const char * signal, bool )
void activate_signal_string ( const char * signal, QString
)
void activate_signal_strref ( const char * signal, const
QString & )
const QObject* sender ()
virtual void initMetaObject ()
virtual void timerEvent ( QTimerEvent * )
virtual void childEvent ( QChildEvent * )
virtual void connectNotify ( const char * signal )
virtual void disconnectNotify ( const char * signal )
virtual bool checkConnectArgs ( const char * signal, const
QObject * receiver, const char * member )
Static Protected Members
QMetaObject* staticMetaObject ()
QCString normalizeSignalSlot ( const char * signalSlot )
void badSuperclassWarning ( const char * className, const
char * superclassName )
RELATED FUNCTION DOCUMENTATION
(Note that these are not member functions.)
void * qt_find_obj_child (QObject * parent, const char *
Properties
Type Name READ WRITE Options
-------------------------------------------
QCString name name setName
DESCRIPTION
The QObject class is the base class of all Qt objects.
QObject is the heart of the Qt object model. The central
feature in this model is a very powerful mechanism for
seamless object commuinication dubbed signals and slots.
With connect(), you can connect a signal to a slot and
destroy the connection again with disconnect(). To avoid
never-ending notification loops, you can temporarily block
signals with blockSignals(). The protected functions
connectNotify() and disconnectNotify() make it possible to
track connections.
QObjects organize themselves in object trees. When you
create a QObject with another object as parent, it will
automatically do an insertChild() on the parent and thus
show up in the parent's children() list. The parent
receives object ownership, i.e. it will automatically
delete its children in its destructor. You can look for an
object by name and optionally type using child() or
queryList(), and get the list of tree roots using
objectTrees().
Every object has an object name() and can report its
className() and whether it inherits() another class in the
QObject inheritance hierarchy.
When an object is deleted, it emits a destroyed() signal.
You can catch this signal to avoid dangling references to
QObjects. The QGuardedPtr class provides an elegant way to
use this feature.
QObjects can receive events through event() and filter
events of other objects. See installEventFilter() and
eventFilter() for details. A convenience handler
childEvent() can be reimplemented to catch child events.
Last but not least, QObject provides the basic timer
support in Qt, see QTimer for high-level support for
timers.
Notice that the Q_OBJECT macro is mandatory for any object
that implement signals, slots or properties. You also need
to run the moc program (Meta Object Compiler) on the
source file. We strongly recommend to use the macro in all
subclasses of QObject regardless whether they actually use
functions can show undefined behaviour.
All Qt widgets inherit QObject. The convenience function
isWidgetType() returns whether an object is actually a
widget. It is much faster than inherits( "QWidget" ).
MEMBER FUNCTION DOCUMENTATION
QObject::QObject ( QObject * parent=0, const char * name=0 )
Constructs an object with the parent object 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.
The object name is a text that can be used to identify
this QObject. It's particularly useful in conjunction with
the Qt Designer. You can find an object by name (and type)
using child(), and more than one using queryList().
See also parent(), name(), child() and queryList().
QObject::~QObject () [virtual]
Destructs the object, deleting all its child objects.
All signals to and from the object are automatically
disconnected.
Warning: All child objects are deleted. If any of these
objects are on the stack or global, your program will
sooner or later crash. We do not recommend holding
pointers to child objects from outside the parent. If you
still do, the QObject::destroyed() signal gives you an
opportunity to detect when an object is destroyed.
void QObject::activate_signal ( const char * signal, const char *
) [protected]
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
void QObject::activate_signal ( const char * signal, int )
[protected]
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
[protected]
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
void QObject::activate_signal ( const char * signal, short )
[protected]
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
void QObject::activate_signal_bool ( const char * signal, bool )
[protected]
For internal use only.
void QObject::activate_signal_string ( const char * signal,
QString ) [protected]
For internal use only.
void QObject::activate_signal_strref ( const char * signal, const
QString & ) [protected]
For internal use only.
void QObject::badSuperclassWarning ( const char * className,
const char * superclassName ) [static protected]
Internal function, called from initMetaObject(). Used to
emit a warning when a class containing the macro Q_OBJECT
inherits from a class that does not contain it.
void QObject::blockSignals ( bool block )
Blocks signals if block is TRUE, or unblocks signals if
block is FALSE.
Emitted signals disappear into hyperspace if signals are
blocked.
bool QObject::checkConnectArgs ( const char * signal, const
QObject * receiver, const char * member ) [virtual
protected]
Returns TRUE if the signal and the member arguments are
compatible, otherwise FALSE.
Warning: We recommend that you do not reimplement this
function but use the default implementation.
QObject* QObject::child ( const char * name, const char * type =
0 )
Searches through the children and grandchildren of this
object for an object named name and with type type (or a
subclass of that type), and returns a pointer to that
object if it exists. If type is 0, any type matches.
If there isn't any such object, this function returns
If there is more than one, one of them is returned; use
queryList() if you need all of them.
void QObject::childEvent ( QChildEvent * ) [virtual protected]
This event handler can be reimplemented in a subclass to
receive child events.
Child events are sent to objects when children are
inserted or removed.
Note that events with QEvent::type() QEvent::ChildInserted
are posted (with QApplication::postEvent()), to make sure
that the child's construction is completed before this
function is called.
If you change state based on ChildInserted events, call
QWidget::constPolish(), or do
QApplication::sendPostedEvents( this,
QEvent::ChildInserted ); in functions that depend on the
state. One notable example is QWidget::sizeHint().
See also event() and QChildEvent.
Reimplemented in QWidgetStack, QGroupBox, QMainWindow,
QWorkspace and QSplitter.
const QObjectList * QObject::children () const
Returns a list of child objects, or 0 if this object has
no children.
The QObjectList class is defined in the qobjcoll.h header
file.
The latest child added is the first object in the list and
the first child added is the last object in the list.
Note that the list order changes when QWidget children are
raised or lowered. A widget that is raised becomes the
last object in the list, and a widget that is lowered
becomes the first object in the list.
See also child(), queryList(), parent(), insertChild() and
removeChild().
const char * QObject::className () const [virtual]
Returns the class name of this object.
This function is generated by the Meta Object Compiler.
Warning: This function will return an invalid name if the
class definition lacks the Q_OBJECT macro.
bool QObject::connect ( const QObject * sender, const char *
signal, const QObject * receiver, const char * member )
[static]
Connects signal from the sender object to member in object
receiver.
You must use the SIGNAL() and SLOT() macros when
specifying the signal and the member.
Example:
QLabel *label = new QLabel;
QScrollBar *scroll = new QScrollBar;
QObject::connect( scroll, SIGNAL(valueChanged(int)),
label, SLOT(setNum(int)) );
This example connects the scroll bar's valueChanged()
signal to the label's setNum() slot. It makes the label
always display the current scroll bar value.
A signal can even be connected to another signal, i.e.
member is a SIGNAL().
class MyWidget : public QWidget
{
public:
MyWidget();
...
signals:
void aSignal();
...
private:
...
QPushButton *aButton;
};
MyWidget::MyWidget()
{
aButton = new QPushButton( this );
connect( aButton, SIGNAL(clicked()), SIGNAL(aSignal()) );
}
In its constructor, MyWidget creates a private button and
connects the clicked() signal to relay clicked() to the
outside world. You can achieve the same effect by
connecting the clicked() signal to a private slot and
emitting aSignal() in this slot, but that takes a few
lines of extra code and is not quite as clear, of course.
A signal can be connected to many slots/signals. Many
signals can be connected to one slot.
If a signal is connected to several slots, the slots are
The function returns TRUE if it successfully connects the
signal to the slot. It will return FALSE when it cannot
connect the signal to the slot.
See also disconnect().
Examples: showimg/main.cpp action/main.cpp
iconview/main.cpp grapher/grapher.cpp xform/xform.cpp
application/main.cpp helpviewer/main.cpp i18n/main.cpp
drawdemo/drawdemo.cpp popup/popup.cpp menu/menu.cpp
qmag/qmag.cpp qwerty/main.cpp forever/forever.cpp
rot13/rot13.cpp scrollview/scrollview.cpp
addressbook/main.cpp movies/main.cpp hello/main.cpp
customlayout/main.cpp mdi/main.cpp
bool QObject::connect ( const QObject * sender, const char *
signal, const char * member ) const
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
Connects signal from the sender object to member in this
object.
Equivalent to: QObject::connect(sender, signal, this,
member).
See also disconnect().
void QObject::connectNotify ( const char * signal ) [virtual
protected]
This virtual function is called when something has been
connected to signal in this object.
Warning: This function violates the object-oriented
principle of modularity. However, it might be useful when
you need to perform expensive initialization only if
something is connected to a signal.
See also connect() and disconnectNotify().
Reimplemented in QClipboard.
void QObject::destroyed () [signal]
This signal is emitted immediately before the object is
destroyed.
All the objects's children are destroyed immediately after
this signal is emitted.
bool QObject::disconnect ( const QObject * sender, const char *
signal, const QObject * receiver, const char * member )
[static]
Disconnects signal in object sender from member in object
receiver.
disconnect() is typically used in three ways, as the
following examples show.
1 Disconnect everything connected to an object's
signals:
disconnect( myObject, 0, 0, 0 );
equivalent to the non-static overloaded function
myObject->disconnect();
2 Disconnect everything connected to a specific
signal:
disconnect( myObject, SIGNAL(mySignal()), 0, 0 );
equivalent to the non-static overloaded function
myObject->disconnect( SIGNAL(mySignal()) );
3 Disconnect a specific receiver.
disconnect( myObject, 0, myReceiver, 0 );
equivalent to the non-static overloaded function
myObject->disconnect( myReceiver );
0 may be used as a wildcard, meaning "any signal", "any
receiving object" or "any slot in the receiving object"
respectively.
The sender may never be 0. (You cannot disconnect signals
from more than one object.)
If signal is 0, it disconnects receiver and member from
any signal. If not, only the specified signal is
disconnected.
If receiver is 0, it disconnects anything connected to
signal. If not, slots in objects other than receiver are
not disconnected.
If member is 0, it disconnects anything that is connected
to receiver. If not, only slots named member will be
disconnected, and all other slots are left alone. The
member must be 0 if receiver is left out, so you cannot
disconnect a specifically-named slot on all objects.
See also connect().
member=0 )
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
Disconnects all signals in this object from member of
receiver.
A signal-slot connection is removed when either of the
objects involved are destroyed.
bool QObject::disconnect ( const char * signal=0, const QObject *
receiver=0, const char * member=0 )
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
Disconnects signal from member of receiver.
A signal-slot connection is removed when either of the
objects involved are destroyed.
void QObject::disconnectNotify ( const char * signal ) [virtual
protected]
This virtual function is called when something has been
disconnected from signal in this object.
Warning: This function violates the object-oriented
principle of modularity. However, it might be useful for
optimizing access to expensive resources.
See also disconnect() and connectNotify().
void QObject::dumpObjectInfo ()
Dumps information about signal connections etc. for this
object to the debug output.
This function is useful for debugging. This function does
nothing if the library has been compiled in release mode
(i.e without debugging information).
void QObject::dumpObjectTree ()
Dumps a tree of children to the debug output.
This function is useful for debugging. This function does
nothing if the library has been compiled in release mode
(i.e without debugging information).
bool QObject::event ( QEvent * e ) [virtual]
This virtual function receives events to an object and
should return TRUE if the event was recognized and
processed.
behavior of an object.
See also installEventFilter(), timerEvent(),
QApplication::sendEvent(), QApplication::postEvent() and
QWidget::event().
Reimplemented in QSplitter, QToolBar, QClipboard,
QSocketNotifier, QStatusBar, QMainWindow, QLineEdit,
QGroupBox, QTimer, QMultiLineEdit and QWidget.
bool QObject::eventFilter ( QObject *, QEvent * ) [virtual]
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.
Warning: If you delete the receiver object in this
function, be sure to return TRUE. If you return FALSE, Qt
sends the event to the deleted object and the program will
crash.
See also installEventFilter().
Reimplemented in QScrollView, QToolBar, QMainWindow,
QTabWidget, QFontDialog, QFileDialog, QSpinBox, QLayout,
QSGIStyle, QAccel, QListView, QComboBox, QTable,
QWorkspace, QMotifPlusStyle, QIconView, QMenuBar and
QWizard.
bool QObject::highPriority () const
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.
bool QObject::inherits ( const char * clname ) const
Returns TRUE if this object is an instance of a class that
inherits clname, and clname inherits QObject.
(A class is considered to inherit itself.)
Example:
QTimer *t = new QTimer; // QTimer inherits QObject
t->inherits("QTimer"); // returns TRUE
t->inherits("QObject"); // returns TRUE
t->inherits("QButton"); // returns FALSE
QScrollBar * s = new QScrollBar; // inherits QWidget and QRangeControl
s->inherits( "QWidget" ); // returns TRUE
See also isA() and metaObject().
void QObject::initMetaObject () [virtual protected]
Initializes the meta object of this object. This method is
automatically executed on demand.
See also metaObject().
void QObject::insertChild ( QObject * obj ) [virtual]
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 be created only
by setting the parent widget in the constructor or by
calling QWidget::reparent().
See also removeChild() and QWidget::reparent().
void QObject::installEventFilter ( const QObject * obj )
Installs an event filter obj for this object.
An event filter is an object that receives all events that
are sent to this object. The filter can either stop the
event or forward it to this object. The event filter obj
receives events via its eventFilter() function. The
eventFilter() function must return TRUE if the event
should be stopped, or FALSE if the event should be
dispatched normally.
If multiple event filters are installed for a single
object, the filter that was installed last is activated
first.
Example:
#include <qwidget.h>
class MyWidget : public QWidget
{
public:
MyWidget::MyWidget( QWidget *parent=0, const char *name=0 );
protected:
bool eventFilter( QObject *, QEvent * );
};
MyWidget::MyWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
if ( parent ) // has a parent widget
parent->installEventFilter( this ); // then install filter
}
bool MyWidget::eventFilter( QObject *o, QEvent *e )
{
if ( e->type() == QEvent::KeyPress ) { // key press
qDebug( "Ate key press %d", k->key() );
return TRUE; // eat event
}
return QWidget::eventFilter( o, e ); // standard event processing
}
The QAccel class, for example, uses this technique.
Warning: If you delete the receiver object in your
eventFilter() function, be sure to return TRUE. If you
return FALSE, Qt sends the event to the deleted object and
the program will crash.
See also removeEventFilter(), eventFilter() and event().
bool QObject::isA ( const char * clname ) const
Returns TRUE if this object is an instance of a specified
class, otherwise FALSE.
Example:
QTimer *t = new QTimer; // QTimer inherits QObject
t->isA("QTimer"); // returns TRUE
t->isA("QObject"); // returns FALSE
See also inherits() and metaObject().
bool QObject::isWidgetType () const
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.
void QObject::killTimer ( int id )
Kills the timer with the identifier id.
The timer identifier is returned by startTimer() when a
timer event is started.
See also timerEvent(), startTimer() and killTimers().
Examples: grapher/grapher.cpp
void QObject::killTimers ()
Kills all timers that this object has started.
Note that using this function can cause hard-to-find bugs:
It kills timers started by sub- and superclasses as well
as those started by you, which is often not what you want.
Therefore, we recommend using a QTimer, or perhaps
killTimer().
See also timerEvent(), startTimer() and killTimer().
QMetaObject * QObject::metaObject () const [virtual]
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,
properties, 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 and the property system. The
functions isA() and inherits() also make use of the meta
object.
const char * QObject::name () const
Returns the name of this object. If the object does not
have a name, it will return "unnamed", so that printf()
(used in qDebug()) will not be asked to output a null
pointer. If you want a null pointer to be returned for
unnamed objects, you can call name( 0 ).
qDebug( "MyClass::setPrecision(): (%s) unable to set precision to %f",
name(), newPrecision );
The object name is set by the constructor or by the
setName() function. The object name is not very useful in
the current version of Qt, but will become increasingly
important in the future.
You can find an object by name (and type) using child(),
and more than one using queryList().
See also setName(), className(), child() and queryList().
const char * QObject::name ( const char * defaultName ) const
Returns the name of this object, or defaultName if the
object does not have a name.
QCString QObject::normalizeSignalSlot ( const char * signalSlot )
[static protected]
Normlizes the signal or slot definition signalSlot by
removing unnecessary whitespaces.
const QObjectList * QObject::objectTrees () [static]
Returns a pointer to the list of all object trees
(respectively their root objects), or 0 if there are no
objects.
The QObjectList class is defined in the qobjcoll.h header
file.
The latest root object created is the first object in the
list and the first root object added is the last object in
See also children(), parent(), insertChild() and
removeChild().
QObject * QObject::parent () const
Returns a pointer to the parent object.
See also children().
QVariant QObject::property ( const char * name ) const
Returns the value of the object's name property.
If no such property exists, the returned variant is
invalid.
Information about all available properties are provided
through the metaObject().
See also setProperty(), QVariant::isValid(), metaObject(),
QMetaObject::propertyNames() and QMetaObject::property().
QObjectList * QObject::queryList ( const char * inheritsClass =
0, const char * objName = 0, bool regexpMatch = TRUE, bool
recursiveSearch = TRUE )
Searches the children and optinally grandchildren of this
object, and returns a list of those objects that are named
or matches objName and inherit ineritsClass. If
inheritsClass is 0 (the default), all classes match. IF
objName is 0 (the default), all object names match.
If regexpMatch is TRUE (the default), objName is a regexp
that the objects's names must match. If regexpMatch is
FALSE, objName is a string and object names must match it
exactly.
Note that ineritsClass uses single inheritance from
QObject, the way inherits() does. According to inherits(),
QMenuBar inherits QWidget but not QMenuData. This does not
quite match reality, but is the best that can be done on
the wide variety of compilers Qt supports.
Finally, if recursiveSearch is TRUE (the default),
queryList() searches nth-generation as well as first-
generation children.
If all this seems a bit complex for your needs, the
simpler function child() may be what you want.
This somewhat contrived example disables all the buttons
in this window:
QObjectList * l = topLevelWidget()->queryList( "QButton" );
QObjectListIt it( *l ); // iterate over the buttons
while ( (obj=it.current()) != 0 ) { // for each found object...
++it;
((QButton*)obj)->setEnabled( FALSE );
}
delete l; // delete the list, not the objects
Warning: Delete the list away as soon you have finished
using it. The list contains pointers that may become
invalid at almost any time without notice - as soon as the
user closes a window you may have dangling pointers, for
example.
See also child(), children(), parent(), inherits(), name()
and QRegExp.
QConnectionList * QObject::receivers ( const char * signal )
const [protected]
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.
void QObject::removeChild ( QObject * obj ) [virtual]
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.
See also insertChild() and QWidget::reparent().
Reimplemented in QScrollView.
void QObject::removeEventFilter ( const QObject * obj )
Removes an event filter object obj from this object. The
request is ignored if such an event filter has not been
installed.
All event filters for this object are automatically
removed when this object is destroyed.
It is always safe to remove an event filter, even during
event filter activation (i.e. from the eventFilter()
function).
See also installEventFilter(), eventFilter() and event().
const QObject * QObject::sender () [protected]
Returns a pointer to the object that sent the signal, if
called in a slot before any function call or signal
emission. Returns an undefined value in all other cases.
Warning: This function will return something apparently
change during any function call, depending on what signal-
slot connections are activated during that call. In Qt 3.0
the value will change more often than in 2.x.
Warning: This function violates the object-oriented
principle of modularity, However, getting access to the
sender might be practical when many signals are connected
to a single slot. The sender is undefined if the slot is
called as a normal C++ function.
void QObject::setName ( const char * name ) [virtual]
Sets the name of this object to name. The default name is
the one assigned by the constructor.
You can find an object by name (and type) using child(),
and more than one using queryList().
See also name(), className(), queryList() and child().
Reimplemented in QWidget and QSignal.
bool QObject::setProperty ( const char * name, const QVariant &
value )
Sets the object's property name to value.
Returne TRUE is the operation was successful, FALSE
otherwise.
Information about all available properties are provided
through the metaObject().
See also property(), metaObject(),
QMetaObject::propertyNames() and QMetaObject::property().
bool QObject::signalsBlocked () const
Returns TRUE if signals are blocked, or FALSE if signals
are not blocked.
Signals are not blocked by default.
See also blockSignals().
int QObject::startTimer ( int interval )
Starts a timer and returns a timer identifier, or returns
zero if it could not start a timer.
A timer event will occur every interval milliseconds until
killTimer() or killTimers() is called. If interval is 0,
then the timer event occurs once every time there are no
more window system events to process.
The virtual timerEvent() function is called with the
QTimerEvent event parameter class when a timer event
If multiple timers are running, the QTimerEvent::timerId()
can be used to find out which timer was activated.
Example:
class MyObject : public QObject
{
public:
MyObject( QObject *parent=0, const char *name=0 );
protected:
void timerEvent( QTimerEvent * );
};
MyObject::MyObject( QObject *parent, const char *name )
: QObject( parent, name )
{
startTimer( 50 ); // 50 millisecond timer
startTimer( 1000 ); // 1 second timer
startTimer( 60000 ); // 1 minute timer
}
void MyObject::timerEvent( QTimerEvent *e )
{
qDebug( "timer event, id=%d", e->timerId() );
}
There is practically no upper limit for the interval value
(more than one year). The accuracy depends on the
underlying operating system. Windows 95 has 55 millisecond
(18.2 times per second) accuracy; other systems that we
have tested (UNIX X11, Windows NT and OS/2) can handle 1
millisecond intervals.
The QTimer class provides a high-level programming
interface with one-shot timers and timer signals instead
of events.
See also timerEvent(), killTimer() and killTimers().
Examples: qmag/qmag.cpp forever/forever.cpp
QMetaObject* QObject::staticMetaObject () [static protected]
The functionality of initMetaObject(), provided as a
static function.
QStringList QObject::superClasses ( bool includeThis = FALSE )
const
This function is obsolete. It is provided to keep old
source working, and will probably be removed in a future
version of Qt. We strongly advise against using it in new
code.
This function is misleadingly named, and cannot be
implemented in a way that fulfills its name.
QPaintDevice and QObject, obviously. And it never can, so
let us kill the function. It will be removed in Qt-3.0
Oh, and the return type was wrong, too. QStringList not
QStrList.
void QObject::timerEvent ( QTimerEvent * ) [virtual protected]
This event handler can be reimplemented in a subclass to
receive timer events for the object.
QTimer provides a higher-level interface to the timer
functionality, and also more general information about
timers.
See also startTimer(), killTimer(), killTimers() and
event().
Reimplemented in QPopupMenu and QMultiLineEdit.
QString QObject::tr ( const char * text, const char * comment )
[static]
Returns a translated version of text in context QObject
and and with comment, or text if there is no appropriate
translated version. All QObject subclasses which use the
Q_OBJECT macro have a reimplementation of this function
which uses the relevant class name as context.
See also QApplication::translate().
QString QObject::tr ( const char * text ) [static]
This is an overloaded member function, provided for
convenience. It differs from the above function only in
what argument(s) it accepts.
Returns a translated version of text in context QObject
and with no comment, or text if there is no appropriate
translated version. All QObject subclasses which use the
Q_OBJECT macro have a reimplementation of this function
which uses the relevant class name as context.
See also QApplication::translate().
bool QObject::activate_filters ( QEvent * e ) [protected]
For internal use only.
void QObject::activate_signal ( const char * signal ) [protected]
For internal use only.
RELATED FUNCTION DOCUMENTATION
void * qt_find_obj_child (QObject * parent, const char * type,
const char * name)
Returns a pointer to the child named name of QObject
parent which inherits type type.
QListBox * c = (QListBox *)::qt_find_obj_child(myWidget,QListBox,
"listboxname");
if ( c )
c->insertItem( "another string" );
SEE ALSO
http://doc.trolltech.com/qobject.html
http://www.trolltech.com/faq/tech.html
COPYRIGHT
Copyright 1992-2001 Trolltech AS,
http://www.trolltech.com. See the license file included
in the distribution for a complete license statement.
AUTHOR
Generated automatically from the source code.
BUGS
If you find a bug in Qt, please report it as described in
http://doc.trolltech.com/bughowto.html. Good bug reports
make our job much simpler. Thank you.
In case of content or formattting problems with this
manual page, please report them to qt-bugs@trolltech.com.
Please include the name of the manual page (qobject.3qt)
and the Qt version (2.3.1).
Man(1) output converted with
man2html