17 #include <QGridLayout>
18 #include <QLayoutItem>
32 void deleteChildWidgets(QLayoutItem* item)
36 for (
int i = 0; i < item->layout()->count(); i++)
37 deleteChildWidgets(item->layout()->itemAt(i));
39 delete item->widget();
49 void remove(QGridLayout* layout,
int row,
int column,
bool deleteWidgets)
52 for (
int i = layout->count() - 1; i >= 0; i--) {
54 layout->getItemPosition(i, &r, &c, &rs, &cs);
55 if ((r <= row && r + rs - 1 >= row) || (c <= column && c + cs - 1 >= column)) {
57 QLayoutItem* item = layout->takeAt(i);
59 deleteChildWidgets(item);
73 while (layout->count() > 0) {
74 QLayoutItem* item = layout->takeAt(0);
76 delete item->widget();
77 if (QLayout* childLayout = item->layout())
94 remove(layout, row, -1, deleteWidgets);
95 layout->setRowMinimumHeight(row, 0);
96 layout->setRowStretch(row, 0);
110 remove(layout, -1, column, deleteWidgets);
111 layout->setColumnMinimumWidth(column, 0);
112 layout->setColumnStretch(column, 0);
117 for (
int i_row = 0; i_row < layout->rowCount(); ++i_row)
123 auto* result =
new QWidget;
124 result->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
Defines namespace GUI::Util::Layout.
void removeColumn(QGridLayout *layout, int column, bool deleteWidgets=true)
Removes column from grid layout.
void removeRow(QGridLayout *layout, int row, bool deleteWidgets=true)
Removes row from grid layout (important: doesn't change row count).
QWidget * placeHolder()
Returns empty widget to occupy place in layout.
void clearLayout(QLayout *layout, bool deleteWidgets=true)
Removes content from box layout.
void clearGridLayout(QGridLayout *layout, bool deleteWidgets=true)
Clear layout completely.