【问题标题】:Call function when press finish on QWizard在 QWizard 上按完成时调用函数
【发布时间】:2018-07-10 16:37:10
【问题描述】:

按下 QWizard 上的完成按钮后如何触发功能?我正在使用 PyQT5。到目前为止,我只在按下“取消”或“完成”按钮时才成功,但是我只需要在按下“完成”按钮时触发

class ImportWizard(QtWidgets.QWizard):
def __init__(self, parent=None):
    super(ImportWizard, self).__init__(parent)
    self.addPage(Page1(self))
    self.addPage(Page2(self))
    self.setWindowTitle("Import Wizard")

    # Trigger close event when pressing Finish button
    app.aboutToQuit.connect(self.onFinish)

def onFinish(self):
    print("Wizard closes")

【问题讨论】:

    标签: python-3.x events pyqt5


    【解决方案1】:

    我刚刚找到它。解决方案是交换app.aboutToQuit.connect(self.onFinish) 符合self.button(QtWidgets.QWizard.FinishButton).clicked.connect(self.onFinish)

    【讨论】:

      猜你喜欢
      • 2019-11-24
      • 1970-01-01
      • 2018-02-20
      • 1970-01-01
      • 1970-01-01
      • 2015-08-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多