qfiledialog

QFileDialog: adding extension automatically when saving file?

爱⌒轻易说出口 提交于 2019-12-04 01:47:18
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 save"); fileDialog.setNameFilter("PDF-Files (*.pdf)"); fileDialog.exec(); QFile pdfFile(fileDialog.selectedFiles().first()); now when the user enters "foo" as the name, the file will be saved as "foo", not as "foo.pdf". So the QFileDialog doesn't add the extension automatically. My question: How can I change this? Caleb Huitt - cjhuitt You could use QFileDialog

PyQt4 File select widget

断了今生、忘了曾经 提交于 2019-12-03 16:25:29
问题 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

PyQt4 File select widget

南笙酒味 提交于 2019-12-03 04:52:33
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? There is no file dialog available from the Qt designer as far as I know. But you can easily

How to use QFileDialog options and retrieve saveFileName?

半腔热情 提交于 2019-12-03 02:53:19
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 suffix, and enabling the Detail view of the save file dialog, which, from what I could tell, isn't possible to do, using the getSaveFileName alone. Whenever I set those, the getSaveFileName dialog just ignored them. So, I ended up with something like this: dlg=QtGui.QFileDialog( self ) dlg.setWindowTitle( 'Print Things' ) dlg.setViewMode( QtGui

Adding QFileDialog as a widget inside another QDialog

淺唱寂寞╮ 提交于 2019-12-02 17:57:55
问题 I'm attempting to create a dialog which contains two child widgets: on the left side a QFileDialog instance so users can select files, and on the right side a separate widget which will be used to show a preview of the selected file if it is of a certain type. The problem is that the dialog opens up and I can see the "preview" widget just fine, but the QFileDialog is not showing up at all. This short example demonstrates my problem: from PyQt5.QtWidgets import * from PyQt5.QtCore import * app

PyQt file browsing - setting a default option?

喜夏-厌秋 提交于 2019-12-02 14:44:39
问题 I've been trying to implement a file browsing widget in the GUI I'm designing. I am using the QFileDialog module, which works great - I can browse and save a file with the following line of code: filenames = QFileDialog.getOpenFileName() My widget is set up with a QLineEdit, which I would like to display the name of the file selected, and a QPushButton, which I would like to initiate the above line of code. However, I'd like to know if there's a way I can set a "default" option. If the browse

Adding QFileDialog as a widget inside another QDialog

一笑奈何 提交于 2019-12-02 09:26:32
I'm attempting to create a dialog which contains two child widgets: on the left side a QFileDialog instance so users can select files, and on the right side a separate widget which will be used to show a preview of the selected file if it is of a certain type. The problem is that the dialog opens up and I can see the "preview" widget just fine, but the QFileDialog is not showing up at all. This short example demonstrates my problem: from PyQt5.QtWidgets import * from PyQt5.QtCore import * app = QApplication([]) main_dialog = QDialog() main_dialog.setWindowTitle('My Dialog') layout =

Qt and files in shared folders

删除回忆录丶 提交于 2019-12-02 07:09:27
问题 Can I use Qt to pick/open files on shared folder? I've tried to use QFileDialog, but it seems that there is no "network" category, as in standrd windows explorer. 回答1: You need to specify which version of Qt you are using. Versions 4.7+ have support for native file dialogs and use them by default. See the accepted answer here: QFileDialog alternative that uses default file dialog defined by OS? In previous versions, there was no easy way to show network shares in the QFileDialog on Windows.

Qt and files in shared folders

假装没事ソ 提交于 2019-12-02 06:44:58
Can I use Qt to pick/open files on shared folder? I've tried to use QFileDialog, but it seems that there is no "network" category, as in standrd windows explorer. kaliatech You need to specify which version of Qt you are using. Versions 4.7+ have support for native file dialogs and use them by default. See the accepted answer here: QFileDialog alternative that uses default file dialog defined by OS? In previous versions, there was no easy way to show network shares in the QFileDialog on Windows. 来源: https://stackoverflow.com/questions/4818108/qt-and-files-in-shared-folders

No files visible in the QFileDialog window

北城余情 提交于 2019-12-01 17:48:48
I am writing a simple code using pyqt In the code, I invoke a QFileDialog , however when I invoke it using the static functions all works fine, but with the normal method i.e. using dialog.exec_(), I do not see any files in the file dialog window. Only after typing the complete path of the file can I see the file in the file dialog window. Note that this issue is only when I invoke the FileDialoghandler function, If I don't do that, no matter how I invoke the QFileDialog , everything works fine. And also this issue is only on Linux, on Windows7 everything works ok. I am wondering whether this