I'm wondering if the QFileDialog class in Qt5 can be modified to change the 'Look in:' dropdown to a Line Edit so that the path can be pasted directly without having to select each folder individually
import sys
from PyQt5.QtWidgets import QApplication, QFileDialog, QWidget, QVBoxLayout, QPushButton, QLabel
class FileDialogExample(QWidget):
def __init__(self):
super(FileDialogExample, self).__init__()
self.initUI()
def initUI(self):
layout = QVBoxLayout()
self.label = QLabel('Selected File: ')
layout.addWidget(self.label)
btnOpenFileDialog = QPushButton('Open File Dialog', self)
btnOpenFileDialog.clicked.connect(self.showDialog)
layout.addWidget(btnOpenFileDialog)
self.setLayout(layout)
def showDialog(self):
options = QFileDialog.Options()
options |= QFileDialog.DontUseNativeDialog
fileName, _ = QFileDialog.getOpenFileName(self, "Open File", "", "All Files (*);;Text Files (*.txt)", options=options)
if fileName:
self.label.setText(f'Selected File: {fileName}')
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = FileDialogExample()
ex.show()
sys.exit(app.exec_())

I'm not sure if it can be done. I've tried searching for information, but haven't found anything yet.
I think you can't change it.
But by default, Qt uses a platform-native file dialog. And at least a Windows file dialog has the behavior you want. Remove this line in your code to get back to the default file dialog: