Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8428697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:07:36+00:00 2026-06-10T05:07:36+00:00

Sorry the title is such a mouth full, but basically what I am trying

  • 0

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)    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:07:38+00:00Added an answer on June 10, 2026 at 5:07 am

    Try to use the sender method:

    def loadFile(self):
        selFile = QtGui.QFileDialog.getOpenFileName()
        if self.sender() == self.qFileButton:
            self.qFileTF.setText(selFile)
        elif self.sender() == self.lhFileTF:
            self.lhFileTF.setText(selFile)
        else:
            self.oldQTF.setText(selFile)      
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry for such a vague title. Basically, I am trying to hack a function
Sorry for such a random title, but have no idea how to explain it
Sorry that I have to describe the functionality in such a roundabout manner, but
Sorry the title may not be very clear. Basically I have a wrapper for
Sorry if the title doesn't make sense. Basically I have a series of strings
Sorry for the none-descriptive title, but I didn't really have a clue as to
First of all Sorry if my question title sounds stupid.... I have the following
Not exactly sure how to phrase this, sorry for ambiguous title. Anyways, here's basically
Sorry for the poor title guys, but I'm whooped. I have a table as
Sorry for such a lame title, but I just had no idea what to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.