Skip to content

Instantly share code, notes, and snippets.

@fmorency
Created July 4, 2012 14:37
Show Gist options
  • Save fmorency/3047689 to your computer and use it in GitHub Desktop.
Save fmorency/3047689 to your computer and use it in GitHub Desktop.
PySide destroy slot
import sys
from PySide.QtCore import *
from PySide.QtGui import *
class MyQWidget(QWidget):
def __init__(self, parent=None, wflags=Qt.WindowFlags()):
super(MyQWidget, self).__init__(parent, wflags)
self.destroyed.connect(self.destroy_slot)
@Slot()
def destroy_slot(self, obj):
print 'Destroying...'
@Slot()
def other_destroy_slot(obj):
print 'Other destroy slot...'
if __name__ == '__main__':
app = QApplication(sys.argv)
main_window = QMainWindow()
my_widget = MyQWidget(main_window)
my_widget.destroyed.connect(other_destroy_slot)
button = QPushButton(main_window)
button.setText('Quit')
button.clicked.connect(app.exit)
main_window.show()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment