views:

35

answers:

1

Hi,

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?

Thanks! Nathan

A: 

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():
    lineEdit.setText(QFileDialog.getOpenFileName())

pushButton.clicked.connect(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.

WoLpH