Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QObject Class Reference

Inheritance diagram for QObject:

AnalogClockPlugin BasicToolsPlugin ByteArrayPrototype Client Counter EchoPlugin ExtraFiltersPlugin ImageItem KeyPressEater ListWidgetItemPrototype ListWidgetPrototype Mouse MultiPageWidgetContainerExtension MyClass MyClass MyClass MyClass MyClass MyHelpHandler MyObject MyObject MyObject MyObject MyObject MyPrivateInitStuff MyScriptableObject Phonon::AbstractAudioOutput Phonon::AbstractMediaStream Phonon::BackendCapabilities::Notifier Phonon::Effect Phonon::Factory::Sender Phonon::MediaController Phonon::MediaObject Q3Accel Q3Action Q3Canvas Q3Dns Q3DragObject Q3EditorFactory Q3FileIconProvider Q3NetworkOperation Q3NetworkProtocol Q3Process Q3ServerSocket Q3Signal Q3SqlForm Q3StyleSheet Q3UrlOperator Q3WhatsThis QAbstractEventDispatcher QAbstractItemDelegate QAbstractItemModel QAbstractMessageHandler QAbstractTextDocumentLayout QAbstractUriResolver QAccessibleBridgePlugin QAccessiblePlugin QAction QActionGroup QAssistantClient QButtonGroup QClipboard QCompleter QCoreApplication QDataWidgetMapper QDBusAbstractAdaptor QDBusAbstractInterface QDBusServer qdesigner_internal::Layout QDesignerFormEditorInterface QDesignerFormWindowManagerInterface QDesignerFormWindowToolInterface QDesignerMetaDataBaseInterface QDesignerWidgetDataBaseInterface QDesignerWidgetFactoryInterface QDrag QEventLoop QExtensionFactory QExtensionManager QFileSystemWatcher QFtp QGraphicsItemAnimation QGraphicsScene QGraphicsSvgItem QGraphicsTextItem QGraphicsWidget QHelpEngineCore QHelpGenerator QHelpSearchEngine QHttp QIconEnginePlugin QIconEnginePluginV2 QImageIOPlugin QInputContext QInputContextPlugin QIODevice QItemSelectionModel QKeyMapper QLayout QLibrary QLocalServer QMimeData QMovie QNetworkAccessManager QNetworkCookieJar QObjectCleanupHandler QPictureFormatPlugin QPluginLoader QScriptEngine QScriptExtensionPlugin QSessionManager QSettings QSharedMemory QShortcut QSignalMapper QSocketNotifier QSound QSqlDriver QSqlDriverPlugin QStyle QStylePlugin QSvgRenderer QSyntaxHighlighter QSystemTrayIcon QtAbstractEditorFactoryBase QtAbstractPropertyManager QTcpServer QTextCodecPlugin QTextDocument QTextObject QThread QThreadPool QTimeLine QTimer QTranslator QtToolBarManager QUiLoader QUndoGroup QUndoStack QValidator QWebFrame QWebHistoryInterface QWebPage QWebPluginFactory QWidget TestGui TestGui TestQString TestQString TestQString Thumbnailer TicTacToeTaskMenu WebActionMapper WorldTimeClockPlugin

List of all members.

Detailed 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 communication called {signals and slots}. You can connect a signal to a slot with connect() and destroy the connection 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, the object will automatically add itself to the parent's children() list. The parent takes ownership of the object i.e. it will automatically delete its children in its destructor. You can look for an object by name and optionally type using findChild() or findChildren().

Every object has an objectName() and its class name can be found via the corresponding metaObject() (see QMetaObject::className()). You can determine whether the object's class inherits another class in the QObject inheritance hierarchy by using the inherits() function.

When an object is deleted, it emits a destroyed() signal. You can catch this signal to avoid dangling references to QObjects.

QObjects can receive events through event() and filter the events of other objects. See installEventFilter() and eventFilter() for details. A convenience handler, childEvent(), can be reimplemented to catch child events.

Events are delivered in the thread in which the object was created; see {Thread Support in Qt} and thread() for details. Note that event processing is not done at all for QObjects with no thread affinity (thread() returns zero). Use the moveToThread() function to change the thread affinity for an object and its children (the object cannot be moved if it has a parent).

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 implements signals, slots or properties. You also need to run the {moc}{Meta Object Compiler} on the source file. We strongly recommend the use of this macro in all subclasses of QObject regardless of whether or not they actually use signals, slots and properties, since failure to do so may lead certain functions to exhibit strange behavior.

All Qt widgets inherit QObject. The convenience function isWidgetType() returns whether an object is actually a widget. It is much faster than {qobject_cast()}{qobject_cast}<QWidget *>({obj}) or {obj}->{inherits()}{inherits}("QWidget").

Some QObject functions, e.g. children(), return a QObjectList. QObjectList is a typedef for QList<QObject *>.

No copy constructor

Definition at line 115 of file qobject.h.

Public Slots

void deleteLater ()


void destroyed (QObject *=0)

Public Member Functions

bool blockSignals (bool b)
const QObjectListchildren () const
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
void dumpObjectInfo ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
virtual bool event (QEvent *)
virtual bool eventFilter (QObject *, QEvent *)
template<typename T>
findChild (const QString &aName=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &aName=QString()) const
bool inherits (const char *classname) const
void installEventFilter (QObject *)
bool isWidgetType () const
void killTimer (int id)
void moveToThread (QThread *thread)
QString objectName () const
QObjectparent () const
QVariant property (const char *name) const
 QObject (QObject *parent=0)
void removeEventFilter (QObject *)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setUserData (uint id, QObjectUserData *data)
bool signalsBlocked () const
int startTimer (int interval)
QThreadthread () const
QObjectUserData * userData (uint id) const
virtual ~QObject ()

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static uint registerUserData ()

Protected Member Functions

virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
 QObject (QObjectPrivate &dd, QObject *parent=0)
int receivers (const char *signal) const
QObjectsender () const
virtual void timerEvent (QTimerEvent *)

Protected Attributes

QObjectData * d_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject


QString objectName
 the name of this object


class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name=QString(), T dummy=0)
qFindChild (const QObject *obj, const QString &name)
QList< T > qFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > qFindChildren (const QObject *obj, const QString &name)
T * qobject_cast (QObject *object)
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index