mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-30 10:33:54 -07:00
[VDE] Proper parent lookup syncs group-by box again (#6396)
* [VDE] Proper parent lookup syncs group-by box again * [VDE] Proper lib inclusion. * [VDE] Lint.
This commit is contained in:
parent
7c7f2dd8d5
commit
dde36183ce
2 changed files with 34 additions and 16 deletions
20
libcockatrice_utility/libcockatrice/utility/qt_utils.h
Normal file
20
libcockatrice_utility/libcockatrice/utility/qt_utils.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#ifndef COCKATRICE_QT_UTILS_H
|
||||
#define COCKATRICE_QT_UTILS_H
|
||||
#include <QObject>
|
||||
|
||||
namespace QtUtils
|
||||
{
|
||||
template <typename T> T *findParentOfType(const QObject *obj)
|
||||
{
|
||||
const QObject *p = obj ? obj->parent() : nullptr;
|
||||
while (p) {
|
||||
if (auto casted = qobject_cast<T *>(const_cast<QObject *>(p))) {
|
||||
return casted;
|
||||
}
|
||||
p = p->parent();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace QtUtils
|
||||
|
||||
#endif // COCKATRICE_QT_UTILS_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue