qfiledialog

QFileDialog as editor for TableView: how to get result?

微笑、不失礼 提交于 2019-12-08 08:04:14
问题 I'm using a QFileDialog as the editor for some columns in a QTableView . This basically works (modulo some focus issues, see here): class DirectorySelectionDelegate(QStyledItemDelegate): def createEditor(self, parent, option, index): editor = QFileDialog(parent) editor.setFileMode(QFileDialog.Directory) editor.setModal(True) return editor def setEditorData(self, editor, index): val = index.model().data(index, Qt.DisplayRole) fs = val.rsplit(os.path.sep, 1) if len(fs) == 2: bdir, vdir = fs

QFileDialog: how to set default filename in “Save as…” dialog

妖精的绣舞 提交于 2019-12-06 18:38:13
问题 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 object: auto export_dialog( new QFileDialog( main_window ) ); export_dialog->setWindowModality( Qt::WindowModal ); export_dialog->setFileMode( QFileDialog::AnyFile ); export_dialog->setAcceptMode( QFileDialog::AcceptSave ); All works fine, except one

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

橙三吉。 提交于 2019-12-06 16:59:08
问题 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 QFileSelect , or something like that, but found nothing similar. Should I implement it by hand? Or, what is the correct way to do this? 回答1: Should I implement it by hand? Or, what is the correct way to do this? Yes, I agree with you that it is a

QFileDialog as editor for TableView: how to get result?

泄露秘密 提交于 2019-12-06 15:21:08
I'm using a QFileDialog as the editor for some columns in a QTableView . This basically works (modulo some focus issues, see here ): class DirectorySelectionDelegate(QStyledItemDelegate): def createEditor(self, parent, option, index): editor = QFileDialog(parent) editor.setFileMode(QFileDialog.Directory) editor.setModal(True) return editor def setEditorData(self, editor, index): val = index.model().data(index, Qt.DisplayRole) fs = val.rsplit(os.path.sep, 1) if len(fs) == 2: bdir, vdir = fs else: bdir = "." vdir = fs[0] editor.setDirectory(bdir) editor.selectFile(vdir) def setModelData(self,

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

断了今生、忘了曾经 提交于 2019-12-05 21:25:56
问题 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 build I found that entering a file name without an extension would save as an ordinary file. The user has to specify the extension in the file string (i.e "test.xml") in order for it to save in the correct format. The code I'm using is below. Is this a

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

折月煮酒 提交于 2019-12-05 03:30:44
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 a file. So far we tried different things FileDialog from QtQuick.Dialogs: filename cannot be set Native dialog via QPlatformFileDialogHelper (naughty private c++ hack): filename cannot be set on Linux (Gnome) Native dialog via static QFileDialog::getSaveFileName(): in Quick application there is no QWidget available for 'parent' QT dialog via

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

风流意气都作罢 提交于 2019-12-04 22:37:35
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 QFileSelect , or something like that, but found nothing similar. Should I implement it by hand? Or, what is the correct way to do this? Should I implement it by hand? Or, what is the correct way to do this? Yes, I agree with you that it is a common thing, but unfortunately you will need to implement this yourself. The good news is that you can do this

'selectedFilters' is not a valid keyword argument

痞子三分冷 提交于 2019-12-04 15:48:28
I use PyQt5 and I have an error when I try to save the file name : csv_file_list = QtWidgets.QFileDialog.getOpenFileName(self, 'Open file', '', '*.csv') fileName = csv_file_list fileName = QtWidgets.QFileDialog.getSaveFileName(self, 'Dialog Title', '/path/to/default/directory', selectedFilters='*.txt') if fileName: print (fileName) And it display me this error : 'selectedFilters' is not a valid keyword argument. I don't know if the error is here because of PyQt5 or not For various reasons, the C++ signatures don't always exactly match the PyQt signatures. This is probably the biggest weakness

QFileDialog that accepts a single file or a single directory

走远了吗. 提交于 2019-12-04 05:11:29
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 that can accept both a file or a directory (it makes sense for my program). QFileDialog::​Options didn't have anything promising. lpapp QFileDialog currently does not support this. I think the main problem for you here is that the FileMode is not a Q_FLAGS and the values are not power of 2, either, and so, you cannot write this to solve this issue.

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

空扰寡人 提交于 2019-12-04 03:37:51
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 build I found that entering a file name without an extension would save as an ordinary file. The user has to specify the extension in the file string (i.e "test.xml") in order for it to save in the correct format. The code I'm using is below. Is this a Qt bug or is there a way to specify in Qt that it should add an extension if one wasn't found? // Get