- 
    Bug 
- 
    Resolution: Out of scope
- 
    P2: Important 
- 
    4.5.2
- 
    None
- 
    Windows, Linux
See attached code,
If you:
1 add a widget to a visible layout
2 remove that widget
3 set that widget's parent to NULL
the widget will appear as a top level window, because in step 1, QLayout::addChildWidget() queues a call to QWidgetPrivate::_q_showIfNotHidden(), which calls setVisible(true) while the parent is NULL, hence the widget becomes a top level widget.
The code explains the motivation for wanting to do it in the first place, the comments copy-pasted are:
// The purpose of this code is to try and identify the correct way to:
//
// * Add a widget (A) to a visible layout (L), and then immediately remove it
// * Delete the layout's widget-parent (P), and ensure widget-A is NOT deleted as if it were still a child of P.
//
      // Approach 1 - do nothing special,
      // but this will result in a being destroyed
      // Approach 2 - set parent to NULL,
      // but this will result in a becoming a window of its own
      // Approach 3 - set parent to a QWidget that is never shown
     // this works but this solution was only discovered after diving into QT code, it is not obvious from reading the documentation