diff options
author | Rym Bouabid <rym.bouabid@qt.io> | 2023-10-09 17:11:38 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-11-22 14:42:17 +0000 |
commit | bf946e8e3ba05af7fd8cb3737082dcfddaabf0e1 (patch) | |
tree | bd737c650873a50f037466d1daeeb0316f38e012 /src/corelib/kernel/qobject.h | |
parent | 1126a590f92b2642d52d51787c4bee8866f1b685 (diff) |
QObject: allow calling findChild() without a name
Add an overload of findChild() without a name argument to be able to
call the function with options value only.
[ChangeLog][QtCore][QObject] Added findChild() overload taking no name.
Task-number: QTBUG-103986
Change-Id: Id06b6041408fcf4cc1eeba975afce03f3a28f858
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/corelib/kernel/qobject.h')
-rw-r--r-- | src/corelib/kernel/qobject.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 3660a5b3c4..5180b2335a 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -140,7 +140,7 @@ public: void killTimer(int id); template<typename T> - T findChild(QAnyStringView aName = {}, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const + T findChild(QAnyStringView aName, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { typedef typename std::remove_cv<typename std::remove_pointer<T>::type>::type ObjType; return static_cast<T>(qt_qFindChild_helper(this, aName, ObjType::staticMetaObject, options)); @@ -157,6 +157,12 @@ public: } template<typename T> + T findChild(Qt::FindChildOptions options = Qt::FindChildrenRecursively) const + { + return findChild<T>({}, options); + } + + template<typename T> QList<T> findChildren(Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { return findChildren<T>(QAnyStringView{}, options); |