Doc: Improve documentation for QObject::findChild

There is a difference between findChild() and findChild("") that was
not explained in the documentation. So, add a sentence to clarify it.

The object's search when there are several direct ancestors was
documented as "undefined". Change it to "first child in children()".

Task-number: QTBUG-103986
Pick-to: 6.6 6.5
Change-Id: I25cb01b87d3b24af498ad494b3f353840ee78807
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Rym Bouabid 2023-11-14 16:02:04 +01:00
parent 55141c59cd
commit 80cdd4e5bb

View File

@ -1986,14 +1986,15 @@ void QObject::killTimer(int id)
Returns the child of this object that can be cast into type T and Returns the child of this object that can be cast into type T and
that is called \a name, or \nullptr if there is no such object. that is called \a name, or \nullptr if there is no such object.
Omitting the \a name argument causes all object names to be matched. A null \a name argument causes all objects to be matched. An empty,
non-null \a name matches only objects whose \l objectName is empty.
The search is performed recursively, unless \a options specifies the The search is performed recursively, unless \a options specifies the
option FindDirectChildrenOnly. option FindDirectChildrenOnly.
If there is more than one child matching the search, the most If there is more than one child matching the search, the most-direct
direct ancestor is returned. If there are several direct ancestor is returned. If there are several most-direct ancestors, the
ancestors, it is undefined which one will be returned. In that first child in children() will be returned. In that case, it's better
case, findChildren() should be used. to use findChildren() to get the complete list of all children.
This example returns a child \c{QPushButton} of \c{parentWidget} This example returns a child \c{QPushButton} of \c{parentWidget}
named \c{"button1"}, even if the button isn't a direct child of named \c{"button1"}, even if the button isn't a direct child of