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

template<typename T>
T * QObject::findChild ( const QString name = QString()  )  const [inline, inherited]

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. Omitting the name argument causes all object names to be matched. The search is performed recursively.

If there is more than one child matching the search, the most direct ancestor is returned. If there are several direct ancestors, it is undefined which one will be returned. In that case, findChildren() should be used.

This example returns a child {QPushButton} of {parentWidget} named {"button1"}:

doc/src/snippets/code/src_corelib_kernel_qobject.cpp 10

This example returns a {QListWidget} child of {parentWidget}:

doc/src/snippets/code/src_corelib_kernel_qobject.cpp 11

This function is not available with MSVC 6. Use qFindChild() instead if you need to support that version of the compiler.
See also:
findChildren(), qFindChild()

Definition at line 162 of file qobject.h.

    { return qFindChild<T>(this, aName); }

Generated by  Doxygen 1.6.0   Back to index