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

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"}:

        QPushButton *button = parentWidget->findChild<QPushButton *>("button1");

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

        QListWidget *list = parentWidget->findChild<QListWidget *>();

Warning:
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 160 of file qobject.h.

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


Generated by  Doxygen 1.6.0   Back to index