Nathan Nathan - 1 year ago 112
Python Question

PyQt4 File select widget

I want to make a QT4 (using QT designer) dialog, that contains a part where a file has to be selected.

Now, I know QFileDialog exists, and I can program something that does what I want.
But can I also just do it in QT designer?

Is there some way to get a "file select" widget in QT designer?
Or, I remember these buttons, having the selected file as a title and a little arrow allowing the user to select another file by the QFileDialog?

So is there a ready made solution, or do I have to program it myself?

Answer Source

There is no file dialog available from the Qt designer as far as I know. But you can easily do it with a few lines of code.

Assuming you have a simple button called pushButton and the path should be stored in lineEdit.

def selectFile():


[edit]Just wondering though, are you using KDE by any chance? If so, than you can use the KUrlRequester for this. It can easily be configured to support anything from files to urls to directories.