summaryrefslogtreecommitdiff
path: root/src/lib.cpp
blob: 22904721f18fc42a572b809e1eb9e9835ef96b2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <QApplication>
#include <QMainWindow>
#include <QWidget>

#include "lib.h"

// shamelessly ripped from https://stackoverflow.com/a/46456214
AssignmentList *getMainWindow() {
	foreach(QWidget *w, QApplication::topLevelWidgets())
		if(AssignmentList *mainWin = qobject_cast<AssignmentList*>(w))
			return mainWin;
	return nullptr;
}

void recursiveClear(QLayout *layout) {
	QLayoutItem *child;
	while((child = layout->takeAt(0)) != nullptr) {
		if(child->layout()) recursiveClear(child->layout());
		delete child->widget();
		delete child;
	}
}