I am using Qt 5.5.0 for Windows. In a dialog using for login as well as register, I use a QVBoxLayout as the main layout of the dialog and add a QGridLayout to the mainLayout. W
If you truly want to get rid of the widgets, you should destruct them. If they were allocated on the heap, you should simply delete
them: this deallocates their memory after destructing them.
Qt keeps track of widget lifetime and a widget being destructed automatically removes itself from its layout, and removes itself from its parent.