[英]Passing parameter from main window to pop-up Qdialog window
I have Qdialog with that I open from main window: 我有从主窗口打开的Qdialog:
Dialog = myDialog(self)
Here is the code from new opened Dialog: 这是新打开的对话框中的代码:
class myDialog(QtGui.QDialog, Ui_DialogCalibration):
def __init__(self, parent=None):
super(myDialog, self).__init__(parent)
self.setupUi(self)
How can pass parameter(lint) from main window to this new window, something like 如何将参数(lint)从主窗口传递到这个新窗口,类似
Dialog = myDialog(self, listInformation)
and then in myDialog class use that list 然后在myDialog类中使用该列表
class myDialog(QtGui.QDialog, Ui_DialogCalibration):
def __init__(self, parent=None, listInfo):
super(myDialog, self).__init__(parent)
self.listInfo = listInfo
self.setupUi(self)
Then, when you go to create the myDialog
, you can add the list as a parameter. 然后,当您创建
myDialog
,可以将列表添加为参数。 When you need to use it inside of your myDialog
, you would access it as self.listInfo
. 当需要在
myDialog
使用它时,可以将其作为self.listInfo
访问。
EDIT: To further expand on the comments: 编辑:要进一步扩展评论:
If you have def __init__(self, parent=None, listInfo=None)
, you would call it as Dialog = myDialog(parent=self, listInfo=listInfo)
. 如果您具有
def __init__(self, parent=None, listInfo=None)
,则将其称为Dialog = myDialog(parent=self, listInfo=listInfo)
。 If you had it as def __init__(self, parent, listInfo)
you would do Dialog = myDialog(self, listInfo)
. 如果将其作为
def __init__(self, parent, listInfo)
,则可以执行Dialog = myDialog(self, listInfo)
。 Hopefully you see the pattern here. 希望您在这里看到了模式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.