qfiledialog

How to set the directory separator character to match the operating system?

一曲冷凌霜 提交于 2019-12-12 17:28:55
问题 I am writing a qt application, with the goal of it being portable to the 3 major operating systems. I am using QFileDialog to select a folder, and then adding it to a QListWidget. However the folder name is being returned as E:/media even though I am on Windows. I would want it to return E:\media I could use a simple string replace, but then on Linux/Mac it would look weird to have \home\user\Documents My code if it helps: void LibrariesForm::on_addButton_clicked() { QString dir = QFileDialog

Crash when calling getOpenFileName from QItemDelegate's custom editor

╄→尐↘猪︶ㄣ 提交于 2019-12-12 01:44:28
问题 Prerequisites: I have a custom QItemDelegate which creates custom editor for treeview items. The editor consists of a QLineEdit and QToolButton. The button is used to open the file dialog for selecting the file and placing it's path into line edit. I use a call to QFileDialog::getOpenFileName to open the file dialog. The dialog is native Windows file dialog (this is important). When the editor is created the first time, everything works ok no matter how often I press that button. But after

How to make QFileDialog not modal in Qt5?

别来无恙 提交于 2019-12-11 09:55:19
问题 In previous versions of Qt we were able to use following constructor of file dialog: QFileDialog(QWidget * parent = 0, const char * name = 0, bool modal = FALSE) So, it looks like it was possible to make non-modal file dialog. But now (in Qt5) we haven't such parameters in constructor. Also QFileDialog ignores setWindowModality(Qt::NonModal); and setModal(false); (I've checked, that if windowModality() == Qt::NonModal && isModal() == false , file dialog window is still modal). Do you have

QFileDialog : how to set option to show content of folder in getExistingDirectory()

不羁的心 提交于 2019-12-11 01:29:51
问题 I am using QFileDialog as filename = QFileDialog::getExistingDirectory(this,"Select Image File: ",dataDir,0); I want that I can check files inside folder before selecting it. function getExistingDirectory() is setting QFileDialog::ShowDirsOnly as a default option. I checked in docs there is no any option that do opposite of this. So I set last parameter 0. But now it is not using native dialog. I want to use native dialog with this. I have no clue how to do this cause no flag found in options

Qt Remote File Browser

谁说胖子不能爱 提交于 2019-12-10 20:51:02
问题 I was wondering if anyone has worked on Qt Remote File Browser. From my understanding, I have two options; Use QFileDilaog with a custom proxy model when it comes to remote files. The model will be responsible for providing remote file/directory structure. Use a custom dialog and have a standard file system model for local files and a custom model for remote files. In both cases, the process of getting remote file/directory list can be accomplished using QNetworkAccess manager. Has anyone

PyQt QFileDialog exec_ is slow

丶灬走出姿态 提交于 2019-12-10 17:48:01
问题 I'm using a custom QFileDialog because I want to select multiple directories. But the exec_ function is very slow, and I can't figure out why. I'm using the newest version of PyQt. Code Snippet: from PyQt4 import QtGui, QtCore, QtNetwork, uic class MainWindow(QtGui.QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) uic.loadUi('gui.ui', self) self.connect(self.multiPackerAddDirsBtn, QtCore.SIGNAL('clicked()'), self.multiPackerAddDirs) def multiPackerAddDirs

Multiple files and folder selection in QFileDialog (Revisited)

左心房为你撑大大i 提交于 2019-12-10 11:54:20
问题 This question already exists here, but the answer appears outdated or no longer works as of Python 2.7. When I use this code to subclass my QFileDialog, the FileDialog class init is called, but the openClicked method is never called. class FileDialog(QtGui.QFileDialog): def __init__(self, *args): QtGui.QFileDialog.__init__(self, *args) self.setOption(self.DontUseNativeDialog, True) self.setFileMode(self.ExistingFiles) btns = self.findChildren(QtGui.QPushButton) self.openBtn = [x for x in btns

pyqt5 - finding documentation

▼魔方 西西 提交于 2019-12-09 18:31:51
问题 I have been working my way through Summerfields book on Rapid GUI programming with Python and QT... pyqt to be preciser, but the book from 2007 uses version 4.something and I am trying to get going with the current version 5.4.2.. There are some changes that I am trying to figure out and would love some assistance on how to find stuff. Here is an example for a file save dialog - from the book: fname = QFileDialog.getSaveFileName(self, "Image Changer - Save Image", fname, "Image files ({})"

QFileDialog that accepts a single file or a single directory

自作多情 提交于 2019-12-09 16:39:49
问题 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. 回答1: QFileDialog currently does not support this. I think the main problem for you here is that the FileMode is not a Q

QFileDialog: adding extension automatically when saving file?

丶灬走出姿态 提交于 2019-12-09 15:00: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