code: def closeEvent(self, event):
          
          if not self.canClose():
              event.ignore()
              return
  
          elif not self.isViewSingleton():
              self.setAttribute(Qt.WA_DeleteOnClose)
  
          else:
              self.setParent(self.window())  # attach the hidden singleton instance to the window vs. anything in the view
  
          super(XView, self).closeEvent(event)
docs: Determines whether or not this widget should be deleted after close.
          
          :param      event | <QtCore.QCloseEvent>