Questions tagged [qfiledialog]

QFileDialog is a class from the Qt toolkit which provides a dialog allowing users to select files or directories.

Documentation can be found here (Qt4) and here (Qt5).

322 questions
23
votes
1 answer

Qt: add a file selection field on the form (QLineEdit and "browse" button)

I need to display QLineEdit with "Browse" button at my form. When user clicks button, QFileDialog should be opened, and so on. This is pretty common thing, but I can't find ready-made solution for that. I expected in Qt Designer some widget like…
Dmitry Frank
  • 9,453
  • 7
  • 55
  • 101
22
votes
3 answers

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…
Nathan
  • 465
  • 2
  • 5
  • 14
15
votes
4 answers

QFileDialog: how to set default filename in "Save as..." dialog

I try to create "Save as..." dialog in Mac OS X. But I don't want to use QFileDialog::getSaveFileName() function, because dialog that created by this function is NOT truly-native in Mac OS X Lion. So I decide to create dialog as QFileDialog…
Denis Shevchenko
  • 1,166
  • 2
  • 9
  • 22
14
votes
1 answer

QFileDialog: adding extension automatically when saving file?

When using a QFileDialog to save a file and to specify the extension (like *.pdf) and the user types in a name without this extension, also the saved file hasn't this extension. Example-Code: QFileDialog fileDialog(this, "Choose file to…
Berschi
  • 2,365
  • 8
  • 33
  • 49
13
votes
2 answers

Multiple files AND folder selection in a QFileDialog?

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…
sahilgupta
  • 135
  • 1
  • 1
  • 8
12
votes
4 answers

QFileDialog that accepts a single file or a single directory

Is it possible to show a QFileDialog where the user can select a file or a directory, either one? QFileDialog::getOpenFileName() accepts only files, while QFileDialog::getExistingDirectory() is directories-only, but I need to show a file dialog…
sashoalm
  • 63,456
  • 96
  • 348
  • 677
12
votes
2 answers

How to use QFileDialog options and retrieve saveFileName?

I'm trying to use a QFileDialog to prompt a user to provide a filename and location to save a text file at. I played around with the QtGui.QFileDialog.getSaveFileName, but I was interested in using some of the options, like setting the default…
user3161430
  • 145
  • 1
  • 1
  • 9
11
votes
3 answers

FileDialog in QTQuick (QML): Save file under given name

We're building a Qt Quick app, that must be able to save a file under a given name. In the FileDialog component you can only set a directory. This is not very user-friendly, since you don't want to type in a filename by hand every time you download…
Simon Warta
  • 8,469
  • 4
  • 32
  • 62
10
votes
1 answer

how to make getOpenFileName remember last opening path?

According to getOpenFileName instructions: QString fileName = QFileDialog.getOpenFileName(this, tr("Open File"), "/home", tr("Images (*.png *.xpm *.jpg)")); How…
Liao Zhuodi
  • 2,366
  • 4
  • 22
  • 39
9
votes
2 answers

QFileDialog::DontUseNativeDialog is not working

I have an issue with a simple program. I'm opening a QFileDialog this way: QFileDialog fileDialog(this); fileDialog.setAcceptMode(QFileDialog::AcceptOpen); if (!fileDialog.exec()) return; However it shows a Qt dialog instead the native Windows…
daleotar
  • 315
  • 3
  • 6
9
votes
1 answer

Qt Android: How to show the native file dialog?

I'm not sure if it is possible, but currently, when I show an open file dialog: QString file = QFileDialog::getOpenFileName(this); The dialog shown is not the native dialog for Android. Instead, it looks like this (it's also not maximized): I'm…
sashoalm
  • 63,456
  • 96
  • 348
  • 677
8
votes
3 answers

Is there a way to automatically add extensions to a file using QFileDialog on Linux

I want the user to be able to enter a name for a file that will be saved as an xml file. Currently on Windows and Mac if you enter "test" as the file name it will automatically add ".xml" which is what I want. Unfortunately when testing a Linux…
Robert Whitley
  • 981
  • 3
  • 13
  • 28
8
votes
5 answers

PyQt - QFileDialog - directly browse to a folder?

Is there any way to directly browse to a folder using QFileDialog? Meaning, instead of double clicking on each folder while navigating to the destination folder, simply enter the path somewhere or use a hotkey like the one (Shift+Command+G) in…
YaronGh
  • 311
  • 2
  • 3
  • 11
7
votes
3 answers

Specify default extension in QFileDialog::getSaveFileName

Is there an equivalent of the lpstrDefExt member of OPENFILENAME struct used in the Win32 function GetSaveFileName? Here's description from MSDN: LPCTSTR lpstrDefExt The default extension. GetOpenFileName and GetSaveFileName append this extension…
sashoalm
  • 63,456
  • 96
  • 348
  • 677
7
votes
1 answer

QFileDialog to open multiple files

I am trying to show a dialog box to open multiple files but seems like it is not working. The following is a function defined in my Class: def loadFiles(self): filter = "TXT (*.txt);;PDF (*.pdf)" file_name = QtGui.QFileDialog() …
codeKiller
  • 4,342
  • 10
  • 41
  • 90
1
2 3
21 22