LozzerJP
LozzerJP

Reputation: 856

Enabling the QT/PyQt QFileDialog "select all" keyboard shortcut on OSX?

I'm developing cross platform apps using PyQt (ver 4.11.4) that use QFileDialog open file dialogs. The file dialogs are all enabled to select multiple files. On Windows, the standard CTRL-A keyboard shortcut selects all files, but on OSX the standard CMD-A keyboard shortcut does nothing.

On OSX, I can use the cursor with the SHIFT or CMD keys to select multiple files, but does anyone know how I can enable the 'select all' keyboard shortcut?

Edit

Following the reply below, I can now get a non-native file dialog to work. This is better than nothing, but ideally, especially on OS X, a native dialog would be much better. Is there any way to get the same effect with the native dialog?

Here is the complete code that works for non-native dialogs (basically the same as the reply below):

    fileDialog = QtGui.QFileDialog()
    fileDialog.setFileMode(QtGui.QFileDialog.ExistingFiles)
    fileDialog.setOption(QtGui.QFileDialog.DontUseNativeDialog)
    fileDialog.exec_()
    filenames = fileDialog.selectedFiles()
    return(filenames)

Upvotes: 1

Views: 465

Answers (1)

Achayan
Achayan

Reputation: 5895

self.fileDlg=QtGui.QFileDialog()
self.fileDlg.setFileMode(QtGui.QFileDialog.AnyFile)
self.fileDlg.setOptions(QtGui.QFileDialog.DontUseNativeDialog)

You can try this maybe, I didn't test on OSX, but reading from bug reports this should be a solution.

Upvotes: 1

Related Questions