I still don't have full control of it. I'm trying to clear a layout from widgets. In the documentation it says

Qt Code:
  1. QLayoutItem * child;
  2. while ((child = layout()->takeAt(0)) != 0)
  3. {
  4. delete child;
  5. }
To copy to clipboard, switch view to plain text mode 

would safely clear a layout. When I use this, the widgets still stay on the screen. So I figure I need to cast the QLayoutItem* pointers to pointers to widgets of my kind, say MyWidget*. When I do that before deleting, the program crashes. Do I need to cast here actually?

Before I saw this in the documentation, I used an approach based on removeWidget(widget), but for that I need to keep a list of pointers to the widgets I added to the layout. It would be much more elegant to rely on the list of pointers that the layout itself is keeping.