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 6102157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:34:56+00:00 2026-05-23T13:34:56+00:00

I am using pyQt4 and want to have a Browse button in my GUI

  • 0

I am using pyQt4 and want to have a Browse button in my GUI which opens up a Dialog box allowing user to select multiple files AND folders.
I have researched quite a bit but din’t find any way to be able to do this.

The QFileDialog.getOpenFileNames() only allows me to choose files and QFileDialog.getExistingDirectory() only allows to choose directories.

Is there any way I can somehow combine their functionality.
Ideally I would like to use the nativeDialogs but that doesn’t seem to be possible.
As a result I am willing to compromise on the looks. Is there any way I can implement the said?

The same question has been asked here as well but the answer is in c++. I need a python implementation.
Allow user to select a file or a folder in QFileDialog

  • 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-05-23T13:34:56+00:00Added an answer on May 23, 2026 at 1:34 pm

    Here’s a hack that should work for you: Create a subclass of QFileDialog that disconnects the “Open” button and reconnects it to a customized function. It’s not guaranteed to work across different versions of Qt, though, since it relies on being able to find specific sub-widgets that may be reconfigured at some point.

    class FileDialog(QtGui.QFileDialog):
        def __init__(self, *args):
            QtGui.QFileDialog.__init__(self, *args)
            self.setOption(self.DontUseNativeDialog, True)
            self.setFileMode(self.ExistingFiles)
            btns = self.findChildren(QtGui.QPushButton)
            self.openBtn = [x for x in btns if 'open' in str(x.text()).lower()][0]
            self.openBtn.clicked.disconnect()
            self.openBtn.clicked.connect(self.openClicked)
            self.tree = self.findChild(QtGui.QTreeView)
    
        def openClicked(self):
            inds = self.tree.selectionModel().selectedIndexes()
            files = []
            for i in inds:
                if i.column() == 0:
                    files.append(os.path.join(str(self.directory().absolutePath()),str(i.data().toString())))
            self.selectedFiles = files
            self.hide()
    
        def filesSelected(self):
            return self.selectedFiles
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a GUI developed using pyqt4 which has a run button. on run
I'm creating a Qt application using PyQt4 in Python. I have chosen the Dialog
I have some code creating a QTabWidget from Python using PyQt4. I want to
I have a Python application (with GUI, using PyQt4) that gets spawned by the
I am new in Python and using PyQt4 for developing the Gui. I want
I'm using a custom QFileDialog because I want to select multiple directories. But the
Trying to build a user interface using PyQt4. Got a dialog window that pops
So I have been trying to write a GUI using Python 3.3 and PyQt4.
I'm creating a User Interface using PyQt4 module . the problem i'am facing is
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler

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.