This uses only qobject_cast here, having static_cast after it is
redundant.
Also remove the topLevelWidgets variable, since we can just
call the method instead.
{
#ifndef IS_KCM
DolphinMainWindow *mainWindow = nullptr;
- const auto topLevelWidgets = QApplication::allWidgets();
- for (const auto widget : topLevelWidgets) {
- if (qobject_cast<DolphinMainWindow *>(widget)) {
- mainWindow = static_cast<DolphinMainWindow *>(widget);
+ for (const auto widget : QApplication::topLevelWidgets()) {
+ mainWindow = qobject_cast<DolphinMainWindow *>(widget);
+ if (mainWindow) {
break;
}
}