code: def addSubWindow(self, widget, windowFlags=0):
          
          if not widget:
              return 0
          
          childFocus = widget.focusWidget()
          
          # child is already a sub window
          if not isinstance(widget, QtGui.QMdiSubWindow):
              child = XMdiSubWindow(self.viewport(), windowFlags)
              child.setAttribute(QtCore.Qt.WA_DeleteOnClose)
              child.setWidget(widget)
          else:
              child = widget
          
          if childFocus:
              childFocus.setFocus()
          
          return super(XMdiArea, self).addSubWindow(child)
docs: Creates a new sub window for this widget, specifically
          creating an XMdiSubWindow class.
          
          :param      widget      | <QtGui.QWidget>
                      windowFlags | <QtCore.Qt.WindowFlags>
          
          :return     <XMdiSubWindow>