简体   繁体   English

如何在其他.py模块中打开Qdialog

[英]how open Qdialog in other .py module

I have done a GUI interface with Qt designer and compiled the .ui file into a .py file. 我已经使用Qt设计器完成了GUI界面,并将.ui文件编译为.py文件。 In main window I have this class: 在主窗口中,我有这个课:

class Projektdlg(QMainWindow, ui_Projekt.Ui_MainWindow):

    def __init__(self, parent=None):
        super(Projektdlg, self).__init__(parent)
        self.setupUi(self)
        self.connect(self.actionCalibration, SIGNAL("triggered()"), self.CalibrationSettings)

I want to open the QDialog from the generated ui_calibration file when clicking on calibration from the tool bar. 在工具栏上单击校准时,我想从生成的ui_calibration文件中打开QDialog How to do that? 怎么做?

def CalibrationSettings(self):

    Dialog = ui_calibration.Ui_DialogCalibration()

All modules are imported 所有模块均进口

Try something like this: 尝试这样的事情:

class myDialog(QtGui.QDialog, Ui_DialogCalibration):
    def __init__(self, parent=None):
        super(myDialog, self).__init__(parent)

        self.setupUi(self)

Then in your class: 然后在您的课程中:

Dialog = myDialog(self)

Then you can call Dialog.show() or Dialog.exec_() 然后可以调用Dialog.show()Dialog.exec_()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM