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

T * qobject_cast< T * > ( QObject object  )  [related, inherited]

QObject::staticMetaObject

This variable stores the meta-object for the class.

A meta-object contains information about a class that inherits QObject, e.g. class name, superclass 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 inherits() function also makes use of the meta-object.

If you have a pointer to an object, you can use metaObject() to retrieve the meta-object associated with that object.

Example:

        QPushButton::staticMetaObject.className();  // returns "QPushButton"

        QObject *obj = new QPushButton;
        obj->metaObject()->className();             // returns "QPushButton"

See also:
metaObject()
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns 0.

The class T must inherit (directly or indirectly) QObject and be declared with the Q_OBJECT macro.

A class is considered to inherit itself.

Example:

        QObject *obj = new QTimer;          // QTimer inherits QObject

        QTimer *timer = qobject_cast<QTimer *>(obj);
        // timer == (QObject *)obj

        QAbstractButton *button = qobject_cast<QAbstractButton *>(obj);
        // button == 0

The qobject_cast() function behaves similarly to the standard C++ dynamic_cast(), with the advantages that it doesn't require RTTI support and it works across dynamic library boundaries.

qobject_cast() can also be used in conjunction with interfaces; see the {tools/plugandpaint}{Plug & Paint} example for details.

Warning:
If T isn't declared with the Q_OBJECT macro, this function's return value is undefined.
See also:
QObject::inherits()

Definition at line 397 of file qobject.h.

Referenced by QToolBar::actionEvent(), Q3MainWindow::addDockWindow(), QAbstractTextDocumentLayout::anchorAt(), Q3ButtonGroup::buttonClicked(), Q3ButtonGroup::buttonPressed(), Q3ButtonGroup::buttonReleased(), Q3ActionGroup::childActivated(), QWidget::childAt(), Q3MainWindow::childEvent(), Q3ActionGroup::childEvent(), QToolBar::childEvent(), Q3ActionGroup::childToggled(), QTextObject::docHandle(), Q3MainWindow::dockWindows(), QAbstractTextDocumentLayout::document(), QTextObject::document(), QCommonStyle::drawComplexControl(), QWindowsStyle::drawControl(), QAbstractItemView::editorDestroyed(), Q3ButtonGroup::event(), QWidget::event(), QFontComboBox::event(), QLabel::event(), QDockWidget::event(), QtWindowListMenu::eventFilter(), QWindowsStyle::eventFilter(), QX11EmbedWidget::eventFilter(), QPlastiqueStyle::eventFilter(), Q3MainWindow::eventFilter(), QItemDelegate::eventFilter(), QPushButton::focusInEvent(), QPushButton::focusOutEvent(), QAbstractTextDocumentLayout::format(), QAbstractTextDocumentLayout::formatIndex(), QInputDialog::getDouble(), QInputDialog::getInteger(), QInputDialog::getItem(), QInputDialog::getText(), Q3Wizard::help(), QMenu::internalDelayedPopup(), Q3DockArea::isDockWindowAccepted(), QTableWidget::items(), QTreeWidget::items(), QListWidget::items(), Q3MainWindow::menuAboutToShow(), QMainWindow::menuBar(), QTextFrame::iterator::operator++(), QTextFrame::iterator::operator--(), QLayout::parentWidget(), QCompleter::pathFromIndex(), QPlastiqueStyle::polish(), QMenu::popup(), QAction::QAction(), QFontComboBox::QFontComboBox(), QIODevice::QIODevice(), QAbstractTextDocumentLayout::registerHandler(), QToolBar::resizeEvent(), QInputContext::sendEvent(), QWidget::setAttribute(), Q3Table::setCellContentFromEditor(), Q3ToolBar::setOrientation(), QDialog::setVisible(), Q3Action::showStatusText(), QCompleter::splitPath(), QWindowsXPStyle::styleHint(), QWindowsStyle::styleHint(), Q3MainWindow::toolBars(), Q3DockWindow::undock(), QPlastiqueStyle::unpolish(), QLayout::widgetEvent(), QWorkspace::windowList(), Q3DockWindow::~Q3DockWindow(), and QToolBar::~QToolBar().

{ return static_cast<T>(reinterpret_cast<T>(0)->staticMetaObject.cast(object)); }


Generated by  Doxygen 1.6.0   Back to index