[PyQt] Two bugs in QFileDialog::getExistingDirectory

Phil Thompson phil at riverbankcomputing.com
Thu Aug 11 09:53:27 BST 2016


On 11 Aug 2016, at 3:35 am, Zhao Lee <redstone-cold at 163.com> wrote:
> 
> For QFileDialog::getExistingDirectory ,
> 
> (1)
> 
> The keyword argument for The dialog's working directory in Qt5 is dir ,
> 
> QString QFileDialog::getExistingDirectory(QWidget *parent = Q_NULLPTR, constQString &caption = QString(), const QString &dir = QString(), Options options = ShowDirsOnly)
> 
>  
> While in PyQt5.7,The keyword argument is directory
> 
> QFileDialog.getExistingDirectory(parent: QWidget = None, caption: str = '', directory: str = '', options: Union[QFileDialog.Options, QFileDialog.Option] = QFileDialog.ShowDirsOnly)

The names of optional arguments in C++ are not part of the API. You will find inconsistencies in the naming of similar arguments. In Python they are part of the API so consistency is more important and changes to a name would be break backwards compatibility.
 
> (2)
> 
> If the user presses Cancel, it should return an empty path(tested with the standarddialogs example in Qt5.7) rather than a dot(.)(This is the current PyQt5.7 behavior )

I can't reproduce this and it would be surprising as PyQt doesn't do anything with the return value apart from convert it to a Python str.

Phil


More information about the PyQt mailing list