Sorry the title is such a mouth full, but basically what I am trying to do here is that I have 3 buttons, all of them open the QFileDialog for the user to choose a file to use. Since the action is the same, I would like to use the same function for all 3, but depending on which button is pressed, I need to update different QLineEdit to reflect the file path in the GuI. How do I go about achieving that?
#Create the prompt for user to load in the q script to use
self.qFileTF = QtGui.QLineEdit("Choose the q script file to use")
self.qFileButton = QtGui.QPushButton("Open")
self.qFileButton.setFixedSize(100,27)
self.fileLayout1.addWidget(self.qFileTF)
self.fileLayout1.addWidget(self.qFileButton)
#Create the prompt for user to load in the light house file to use
self.lhFileTF = QtGui.QLineEdit("Choose the light house file to use")
self.lhButton = QtGui.QPushButton("Open")
self.lhButton.setFixedSize(100,27)
self.fileLayout2.addWidget(self.lhFileTF)
self.fileLayout2.addWidget(self.lhButton)
#Create the prompt for user to choose to reference an older version of q script
self.oldQCB = QtGui.QCheckBox("Reference an older version Q script")
self.oldQTF = QtGui.QLineEdit("Choose the q script file to use")
self.oldQTF.setEnabled(False)
self.oldQButton = QtGui.QPushButton("Open")
self.oldQButton.setEnabled(False)
self.oldQButton.setFixedSize(100,27)
self.fileLayout3.addWidget(self.oldQTF)
self.fileLayout3.addWidget(self.oldQButton)
self.connect(self.qFileButton, QtCore.SIGNAL("clicked()"), self.loadFile)
self.connect(self.lhButton, QtCore.SIGNAL("clicked()"), self.loadFile)
self.connect(self.oldQButton, QtCore.SIGNAL("clicked()"), self.loadFile)
def loadFile(self):
selFile = QtGui.QFileDialog.getOpenFileName()
if self.qFileButton:
self.qFileTF.setText(selFile)
elif self.lhFileTF:
self.lhFileTF.setText(selFile)
else:
self.oldQTF.setText(selFile)
Try to use the
sendermethod: