qfiledialog

QFileDialog view folders and files but select folders only?

自闭症网瘾萝莉.ら 提交于 2019-11-29 17:16:20
I'm creating my own custom file dialog using the following code: file_dialog = QtGui.QFileDialog() file_dialog.setFileMode(QtGui.QFileDialog.Directory) file_dialog.setViewMode(QtGui.QFileDialog.Detail) file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog, True) The behaviour that i'm interested in is for the user to be able to view both files and folders, but select folders only. (making files unselectable). Is that possible? Note: Using the DirectoryOnly option is not good for me since it doesn't allow you to view files, just folders. Edit (extra code that i forgot to add which

QFileDialog::DontUseNativeDialog is not working

点点圈 提交于 2019-11-29 04:17:56
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 dialog. I'm using Windows 7 x64 and I really do preferr the native dialog instead of Qt dialog because it is a lil' bit more fancy. However I've read and I found that this can be changed by using: fileDialog.setOption(QFileDialog::DontUseNativeDialog, false); The fact is that I'm not getting the native Windows dialog but the Qt one, so that option is not

Copy path to QString

混江龙づ霸主 提交于 2019-11-28 10:53:35
问题 I need to copy the full filepath, without filename, into a QString from QFileDialog below. QString fileName = QFileDialog::getOpenFileName(this, tr("Select app to install"), '/' , tr("APK Files (*.apk)")); 回答1: You use QString QFileInfo::absolutePath() const for this. See the documentation for details. QFileInfo fileInfo(QFileDialog::getOpenFileName(this, tr("Select app to install"), '/' , tr("APK Files (*.apk)"))); qDebug() << fileInfo.absolutePath(); 来源: https://stackoverflow.com/questions

PyQt QFileDialog - Multiple Directory Selection

蓝咒 提交于 2019-11-28 05:04:58
问题 I am trying to create a QFileDialog that allows the user to select multiple directories. Following the discussion here and the faq here, but I'm not sure what I'm doing wrong. I get a file dialog, but it still only lets me select a single directory (folder). This is on Windows 7 Code: class FileDialog(QtGui.QFileDialog): def __init__(self, *args): QtGui.QFileDialog.__init__(self, *args) self.setOption(self.DontUseNativeDialog, True) self.setFileMode(self.DirectoryOnly) self.tree = self

Filtering in QFileDialog

一曲冷凌霜 提交于 2019-11-28 01:17:55
I would like to filter the files that are shown in a QFileDialog more specifically than just by file extensions. The examples I found in the Qt documentation only show filters like Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml) and such. In addition to this I would also like to specify a filter for files that should not show up in the file dialog, e.g. XML files (*.xml) but not Backup XML files (*.backup.xml) . So the problem I have is that I would like to show some files in the file dialog that have certain file extension, but I would not like to show other files with a

QFileDialog::DontUseNativeDialog is not working

耗尽温柔 提交于 2019-11-27 18:17:22
问题 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 dialog. I'm using Windows 7 x64 and I really do preferr the native dialog instead of Qt dialog because it is a lil' bit more fancy. However I've read and I found that this can be changed by using: fileDialog.setOption(QFileDialog::DontUseNativeDialog,

QFileDialog view folders and files but select folders only?

孤人 提交于 2019-11-27 08:36:37
问题 I'm creating my own custom file dialog using the following code: file_dialog = QtGui.QFileDialog() file_dialog.setFileMode(QtGui.QFileDialog.Directory) file_dialog.setViewMode(QtGui.QFileDialog.Detail) file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog, True) The behaviour that i'm interested in is for the user to be able to view both files and folders, but select folders only. (making files unselectable). Is that possible? Note: Using the DirectoryOnly option is not good for me

qfiledialog - Filtering Folders?

冷暖自知 提交于 2019-11-27 05:36:00
1)I want to get the name of the folder for a folder monitoring Application.. Is there a way that i can filter out specific folders from being displayed using QFileDialog (For example i don't want the my documents to be displayed in the file dialog).. 2)I don't want the user to select a drive. By default in this code drives can also be selected.. dirname=QtGui.QFileDialog.getExistingDirectory(self,'Open Directory','c:\\',QtGui.QFileDialog.ShowDirsOnly) print(dirname) Is there a way that i can gray out the drives or some specific folders so that it can't be selected or can i set the filters for

Filtering in QFileDialog

扶醉桌前 提交于 2019-11-26 21:53:21
问题 I would like to filter the files that are shown in a QFileDialog more specifically than just by file extensions. The examples I found in the Qt documentation only show filters like Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml) and such. In addition to this I would also like to specify a filter for files that should not show up in the file dialog, e.g. XML files (*.xml) but not Backup XML files (*.backup.xml) . So the problem I have is that I would like to show some files

Is there a difference between QFileDialog strings in PyQt4 and PyQt5?

夙愿已清 提交于 2019-11-26 06:08:17
问题 I have a block of code that opens a QFileDialog using Python3 and PyQt5: from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QFileDialog import sys class MCVE(QWidget): def __init__(self): super().__init__() self.initialize() def initialize(self): self.setWindowTitle(\'MCVE\') self.setGeometry(50, 50, 400, 200) btn = QPushButton(\'Example\', self) btn.clicked.connect(self.clicked) self.show() def clicked(self): filename = QFileDialog.getOpenFileName( self, \"Open Template\", \"c:\