Qt 4.8
Classes | Macros | Typedefs | Functions
qobject.h File Reference
#include <QtCore/qobjectdefs.h>
#include <QtCore/qstring.h>
#include <QtCore/qbytearray.h>
#include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>

Go to the source code of this file.

Classes

class  QObject
 The QObject class is the base class of all Qt objects. More...
 
class  QObjectData
 
class  QObjectUserData
 

Macros

#define Q_DECLARE_INTERFACE(IFace, IId)
 

Typedefs

typedef QList< QObject * > QObjectList
 

Functions

Q_CORE_EXPORT QDebug operator<< (QDebug, const QObject *)
 
qFindChild (const QObject *o, const QString &name=QString())
 
QList< T > qFindChildren (const QObject *oobj, const QString &name=QString())
 
QList< T > qFindChildren (const QObject *o, const QRegExp &re)
 
template<class T >
qobject_cast (QObject *object)
 
template<class T >
qobject_cast (const QObject *object)
 
template<class T >
const char * qobject_interface_iid ()
 
Q_CORE_EXPORT QObjectqt_qFindChild_helper (const QObject *parent, const QString &name, const QMetaObject &mo)
 
Q_CORE_EXPORT void qt_qFindChildren_helper (const QObject *parent, const QString &name, const QRegExp *re, const QMetaObject &mo, QList< void *> *list)
 

Macro Definition Documentation

◆ Q_DECLARE_INTERFACE

#define Q_DECLARE_INTERFACE (   IFace,
  IId 
)
Value:
template <> inline const char *qobject_interface_iid<IFace *>() \
{ return IId; } \
template <> inline IFace *qobject_cast<IFace *>(QObject *object) \
{ return reinterpret_cast<IFace *>((object ? object->qt_metacast(IId) : 0)); } \
template <> inline IFace *qobject_cast<IFace *>(const QObject *object) \
{ return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0)); }
T * qobject_cast(QObject *object)
Definition: qobject.h:375
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111

Definition at line 397 of file qobject.h.

Referenced by QDeclarativeDebugServerConnection::~QDeclarativeDebugServerConnection(), QDeclarativeExtensionInterface::~QDeclarativeExtensionInterface(), QDeclarativeInspectorInterface::~QDeclarativeInspectorInterface(), QFactoryInterface::~QFactoryInterface(), and QTextObjectInterface::~QTextObjectInterface().

Typedef Documentation

◆ QObjectList

typedef QList<QObject*> QObjectList
related

Definition at line 75 of file qobject.h.

Function Documentation

◆ operator<<()

Q_CORE_EXPORT QDebug operator<< ( QDebug  ,
const QObject  
)

Definition at line 4030 of file qobject.cpp.

4030  {
4031 #ifndef Q_BROKEN_DEBUG_STREAM
4032  if (!o)
4033  return dbg << "QObject(0x0) ";
4034  dbg.nospace() << o->metaObject()->className() << '(' << (void *)o;
4035  if (!o->objectName().isEmpty())
4036  dbg << ", name = " << o->objectName();
4037  dbg << ')';
4038  return dbg.space();
4039 #else
4040  qWarning("This compiler doesn't support streaming QObject to QDebug");
4041  return dbg;
4042  Q_UNUSED(o);
4043 #endif
4044 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ qFindChild()

QT_DEPRECATED T qFindChild ( const QObject o,
const QString name = QString() 
)
inline

Definition at line 355 of file qobject.h.

356 { return o->findChild<T>(name); }
const char * name
T findChild(const QString &aName=QString()) const
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object.
Definition: qobject.h:158

◆ qFindChildren() [1/2]

QT_DEPRECATED QList< T > qFindChildren ( const QObject oobj,
const QString name = QString() 
)
inline

Definition at line 359 of file qobject.h.

360 {
361  return o->findChildren<T>(name);
362 }
const char * name

◆ qFindChildren() [2/2]

QT_DEPRECATED QList< T > qFindChildren ( const QObject o,
const QRegExp re 
)
inline

Definition at line 366 of file qobject.h.

367 {
368  return o->findChildren<T>(re);
369 }
QList< T > findChildren(const QString &aName=QString()) const
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
Definition: qobject.h:162

◆ qobject_cast() [1/2]

template<class T >
T qobject_cast ( QObject object)
related

Definition at line 375 of file qobject.h.

Referenced by QActionGroupPrivate::_q_actionChanged(), QActionGroupPrivate::_q_actionHovered(), QActionGroupPrivate::_q_actionTriggered(), QPlainTextEditPrivate::_q_adjustScrollbars(), QStateMachinePrivate::_q_animationFinished(), QMdiAreaPrivate::_q_deactivateAllWindows(), QMdiSubWindowPrivate::_q_enterInteractiveMode(), QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointEnableRequest(), QScriptDebuggerCodeWidgetPrivate::_q_onBreakpointToggleRequest(), QScriptDebuggerLocalsWidgetPrivate::_q_onCompletionTaskFinished(), QScriptDebuggerConsoleWidgetPrivate::_q_onCompletionTaskFinished(), QMdiAreaPrivate::_q_processWindowStateChanged(), QFileDialogPrivate::_q_showHeader(), QTextCursorPrivate::aboutToRemoveCell(), QAccessibleAbstractSpinBox::abstractSpinBox(), QAccessibleButton::actionText(), QTextCursorPrivate::adjustCursor(), QDockAreaLayoutInfo::apply(), QToolBarAreaLayout::apply(), QStateMachinePrivate::applyProperties(), QStyleSheetStyleSelector::attribute(), QAudioDeviceFactory::audioDeviceInfo(), QAudioDeviceFactory::availableDevices(), QAccessibleButton::button(), QTextDocumentPrivate::changeObjectFormat(), QAccessibleTree::childAt(), QAccessibleTree::childCount(), childWidgets(), QAccessibleComboBox::comboBox(), QTextCursorPrivate::complexSelectionTable(), QShortcutMap::correctContext(), QShortcutMap::correctGraphicsWidgetContext(), QShortcutMap::correctWidgetContext(), QDeclarativeGridViewPrivate::createComponentItem(), QAudioDeviceFactory::createInputDevice(), QAudioDeviceFactory::createOutputDevice(), createReadHandlerHelper(), QTextTablePrivate::createTable(), QGLGraphicsSystem::createWindowSurface(), QTextCursor::currentList(), QTextCursor::currentTable(), QAudioDeviceFactory::defaultInputDevice(), QAudioDeviceFactory::defaultOutputDevice(), QWidget::destroy(), QAccessibleButton::doAction(), dockedGeometry(), QDockWidgetItem::dockWidgetLayout(), QAccessibleTitleBar::dockWidgetLayout(), QTextDocumentLayoutPrivate::drawFrame(), QMdiSubWindowPrivate::drawTitleBarWhenMaximized(), QDockWidgetPrivate::endDrag(), QUIKitSoftwareInputHandler::eventFilter(), QWindowsStyle::eventFilter(), QZipWriter::exists(), QZipReader::exists(), QTextDocumentWriter::fileName(), QImageWriter::fileName(), QImageReader::fileName(), QTextStreamPrivate::fillReadBuffer(), findMenubarForWindow(), QTextStreamPrivate::flushWriteBuffer(), QGraphicsItemPrivate::genericMapFromScene(), QScriptDebuggerLocalsModelPrivate::get(), getNamedAttribute(), QScriptDebuggerScriptedConsoleCommandJob::handleResponse(), handleSplitterContentsAttribute(), handleSplittersAttribute(), QAccessibleHeader::header(), QAInterface::hiObject(), QAccessibleDisplay::imagePosition(), QAccessibleDisplay::imageSize(), QAccessibleTree::indexFromLogical(), QAccessibleTree::indexOfChild(), QAccessibleStackedWidget::indexOfChild(), QAccessibleToolBox::indexOfChild(), QDockWidgetPrivate::initDrag(), QToolBarPrivate::initDrag(), QStateMachinePrivate::initializeAnimation(), initializeDb(), QDialogButtonBoxPrivate::initLayout(), QDockWidget::initStyleOption(), QTextDocumentPrivate::insert_block(), QTextDocumentPrivate::insert_string(), QTreeWidgetItem::insertChildren(), QTextDocumentPrivate::insertFrame(), QMdiAreaPrivate::internalRaise(), QDockWidgetPrivate::isAnimating(), isEmptyBlockAfterTable(), isEmptyBlockBeforeTable(), isItemView(), isLineSeparatorBlockAfterTable(), QScriptDebuggerLocalsModelPrivate::isTopLevelNode(), EGLNullWSWindowSurface::isValid(), QGraphicsScenePrivate::itemsAtPosition(), QAccessibleItemView::itemView(), QTextDocumentLayoutPrivate::layoutFlow(), QTabBarPrivate::layoutTabs(), QAccessibleLineEdit::lineEdit(), QListWidgetPrivate::listModel(), QSvgIOHandlerPrivate::load(), loadSingleEngine(), QAccessibleMainWindow::mainWindow(), QGestureEvent::mapToGraphicsScene(), mdiAreaNavigate(), QAccessibleMenu::menu(), QAccessibleMenuBar::menuBar(), ModelIndexIterator::ModelIndexIterator(), QDockWidgetPrivate::mouseDoubleClickEvent(), QDockWidgetPrivate::mouseMoveEvent(), QToolBarPrivate::mouseMoveEvent(), QDockWidgetPrivate::mousePressEvent(), QTextDocumentPrivate::move(), QTextCursorPrivate::movePosition(), QVNCIntegration::moveToScreen(), my_jpeg_source_mgr::my_jpeg_source_mgr(), QAccessibleDisplay::navigate(), QAccessibleMdiSubWindow::navigate(), QPdfBaseEngine::newPage(), QAccessibleItemView::object(), QLayout::parentWidget(), QAccessibleProgressBar::progressBar(), q_createNativeChildrenAndSetParent(), QOpenKODEWindow::QOpenKODEWindow(), QRenderRule::QRenderRule(), qt_GetMessageHook(), qt_guiPlatformMenuBarFactory(), qt_mac_unregister_widget(), qt_mainwindow_layout(), QAxClientSite::qt_metacall(), qt_x11_recreateNativeWidgetsRecursive(), QTestLiteStaticInfoPrivate::QTestLiteStaticInfoPrivate(), QTreeWidgetItem::QTreeWidgetItem(), QTreeWidgetItemIterator::QTreeWidgetItemIterator(), QAccessible::queryAccessibleInterface(), QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(), QVNCIntegration::QVNCIntegration(), QAccessibleDockWidget::rect(), QAccessibleTitleBar::rect(), QAccessibleDisplay::relationTo(), QTextDocumentPrivate::remove_block(), QTextDocumentPrivate::remove_string(), QMdiSubWindowPrivate::removeButtonsFromMenuBar(), QAccessibleDisplay::role(), QTextDocumentPrivate::rootFrame(), QTestAccessibility::rootObjectHandler(), QAccessibleTree::rowCount(), QAccessibleTable2Cell::rowIndex(), QTextDocumentPrivate::scan_frames(), QAccessibleScrollBar::scrollBar(), QWidgetPrivate::scrollChildren(), QTextCursorPrivate::selectedTableCells(), QTextDocumentPrivate::setBlockFormat(), QTreeWidgetItem::setData(), QOpenKODEWindow::setGeometry(), QRasterWindowSurface::setGeometry(), QInputDialogPrivate::setInputWidget(), QMdiSubWindowPrivate::setMaximizeMode(), QWidgetPrivate::setModal_sys(), QLocalSocket::setSocketDescriptor(), QDockWidgetPrivate::setWindowState(), QFileDialogComboBox::showPopup(), showToolTip(), QAccessibleSlider::slider(), QTreeWidgetItemPrivate::sortChildren(), QTreeWidgetItem::sortChildren(), QAbstractTransitionPrivate::sourceState(), QAccessibleSpinBox::spinBox(), QHttpNetworkReply::sslConfiguration(), QScriptDebuggerScriptedConsoleCommandJob::start(), QToolBarPrivate::startDrag(), QAccessibleButton::state(), QAccessibleTable2Cell::state(), QMdiAreaTabBar::subWindowFromIndex(), QMdiAreaPrivate::subWindowList(), QImageWriter::supportedImageFormats(), QImageReader::supportedImageFormats(), QAccessibleTabBar::tabBar(), QTreeWidgetItem::takeChild(), QTreeWidgetItem::takeChildren(), IsWindowAndNotDrawerOrSheetTest::test(), QAccessibleButton::text(), QAccessibleDisplay::text(), QAccessibleToolButton::toolButton(), QKeyMapperPrivate::translateKeyEvent(), QTextDocumentPrivate::undoRedo(), QDockWidgetPrivate::unplug(), QDockWidgetPrivate::updateButtons(), QWidgetBackingStore::updateLists(), QDockAreaLayoutInfo::updateTabBar(), QScriptDebuggerLocalsItemDelegate::validateInput(), QAccessibleTable2::view(), QAxAggregated::widget(), QAccessibleWidget::widget(), QLayout::widgetEvent(), QAccessibleWidgetStack::widgetStack(), QAxScriptSite::window(), QTextOdfWriter::writeFrame(), QSQLiteResult::~QSQLiteResult(), and QTreeWidgetItem::~QTreeWidgetItem().

376 {
377 #if !defined(QT_NO_QOBJECT_CHECK)
378  reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
379 #endif
380  return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
381 }

◆ qobject_cast() [2/2]

template<class T >
T qobject_cast ( const QObject object)
inline

Definition at line 384 of file qobject.h.

385 {
386 #if !defined(QT_NO_QOBJECT_CHECK)
387  reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
388 #endif
389  return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
390 }

◆ qobject_interface_iid()

template<class T >
const char* qobject_interface_iid ( )
inline

Definition at line 393 of file qobject.h.

394 { return 0; }

◆ qt_qFindChild_helper()

Q_CORE_EXPORT QObject* qt_qFindChild_helper ( const QObject parent,
const QString name,
const QMetaObject mo 
)
Warning
This function is not part of the public interface.

Definition at line 1924 of file qobject.cpp.

Referenced by QObject::findChild(), and qt_qFindChild_helper().

1925 {
1926  if (!parent)
1927  return 0;
1928  const QObjectList &children = parent->children();
1929  QObject *obj;
1930  int i;
1931  for (i = 0; i < children.size(); ++i) {
1932  obj = children.at(i);
1933  if (mo.cast(obj) && (name.isNull() || obj->objectName() == name))
1934  return obj;
1935  }
1936  for (i = 0; i < children.size(); ++i) {
1937  obj = qt_qFindChild_helper(children.at(i), name, mo);
1938  if (obj)
1939  return obj;
1940  }
1941  return 0;
1942 }
QString objectName
the name of this object
Definition: qobject.h:114
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * cast(QObject *obj) const
Returns obj if object obj inherits from this meta-object; otherwise returns 0.
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197
QObject * qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo)
Definition: qobject.cpp:1924

◆ qt_qFindChildren_helper()

Q_CORE_EXPORT void qt_qFindChildren_helper ( const QObject parent,
const QString name,
const QRegExp re,
const QMetaObject mo,
QList< void *> *  list 
)
Warning
This function is not part of the public interface.

Definition at line 1900 of file qobject.cpp.

Referenced by QObject::findChildren(), and qt_qFindChildren_helper().

1902 {
1903  if (!parent || !list)
1904  return;
1905  const QObjectList &children = parent->children();
1906  QObject *obj;
1907  for (int i = 0; i < children.size(); ++i) {
1908  obj = children.at(i);
1909  if (mo.cast(obj)) {
1910  if (re) {
1911  if (re->indexIn(obj->objectName()) != -1)
1912  list->append(obj);
1913  } else {
1914  if (name.isNull() || obj->objectName() == name)
1915  list->append(obj);
1916  }
1917  }
1918  qt_qFindChildren_helper(obj, name, re, mo, list);
1919  }
1920 }
void qt_qFindChildren_helper(const QObject *parent, const QString &name, const QRegExp *re, const QMetaObject &mo, QList< void *> *list)
Definition: qobject.cpp:1900
QString objectName
the name of this object
Definition: qobject.h:114
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QObject * cast(QObject *obj) const
Returns obj if object obj inherits from this meta-object; otherwise returns 0.
int indexIn(const QString &str, int offset=0, CaretMode caretMode=CaretAtZero) const
Attempts to find a match in str from position offset (0 by default).
Definition: qregexp.cpp:4136
const char * name
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
const QObjectList & children() const
Returns a list of child objects.
Definition: qobject.h:197