from PyQt5 import QtCore, QtWidgets
#from PyQt4 import QtCore, QtGui as QtWidgets


def run():
    global model, button
    app = QtWidgets.QApplication([])
    model = Model()
    button = QtWidgets.QPushButton("Open dialog")
    button.resize(400, 300)
    button.clicked.connect(buttonClicked)
    button.show()
    app.exec_()


def buttonClicked():
    dialog = Dialog(button)
    dialog.exec_()
    if dialog.result() == QtWidgets.QDialog.Accepted:
        model.changeSomething()
    #dialog.deleteLater()


class Model(QtCore.QObject):
    changed = QtCore.pyqtSignal()

    def changeSomething(self):
        self.changed.emit()


class Dialog(QtWidgets.QDialog):
    def __init__(self, parent):
        super().__init__(parent)
        layout = QtWidgets.QHBoxLayout(self)
        okButton = QtWidgets.QPushButton("Accept")
        layout.addWidget(okButton)
        okButton.clicked.connect(self.accept)
        model.changed.connect(self._modelChanged)

    #@QtCore.pyqtSlot()
    def _modelChanged(self):
        print("MODEL CHANGED")


if __name__ == "__main__":
    run()