从父文件连接函数

时间:2017-01-27 03:42:08

标签: python python-2.7 pyqt pyqt4

我有两个文件:qdialog1.pyqdialog2.py

qdialog2被拒绝时,我需要从qdialog1

连接myfunction

qdialog1是父级,qdialog2是其子级

谁能帮帮我?

qdialog1.py

from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import QDialog

from Ui_dialog1 import Ui_dialog1
from qdialog2 import Qdialog2

class QDialog1(QDialog, Ui_dialog1):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)

    @pyqtSignature("")
    def on_pbUpdate_clicked(self):
        dlg = QDialog2(self)
        dlg.setModal(True)
        dlg.show()

    def myfunction(self):
        self.lineedit.clear()

qdialog2.py

from PyQt4.QtCore import pyqtSignature
from PyQt4.QtGui import QDialog

from Ui_dialog2 import Ui_dialog2

class QDialog2(QDialog, Ui_dialog2):
    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.setupUi(self)
        self.rejected.connect() # I need help here to call qdialog1.myfunction()

1 个答案:

答案 0 :(得分:0)

您必须通过父

连接
self.rejected.connect(parent.myfunction)