Cleaning QFormLayout
Solved
General and Desktop
-
Hi,
I'm using a QFormLayout to display rows of QString and QSpinBox
I need to clean the content of my layout to add new row.I have tried things like removeItem(itemAt()) but it's not working, i still have some labels superposition.
Thx
EDIT : I have also tried takeAt(0) but i have error like : QFormLayout::takeAt: Invalid index 0
-
Hi
The layout owns the widgets so u should use
takeAt to transfer ownership back if you plan on deleting the
"row" widgets u remove.try this for clean all.
void clearLayout(QLayout *layout) { if (layout) { while(layout->count() > 0){ QLayoutItem *item = layout->takeAt(0); delete item->widget(); delete item; } } }
-
Hi,
There's currently no way to directly remove or remove + delete content of a QFormLayout. But there's a work in progress patch for that.