def closeEvent(self, QCloseEvent):
reply = QtGui.QMessageBox.question(self, 'Message',
'Are you sure to quit?',
QtGui.QMessageBox.Yes,
QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
QCloseEvent.accept()
else:
QCloseEvent.ignore()