File Dialog 'Save as type' selection

  • I'm using a Qt File dialog to save files, but haven't been able to find how to set the 'Save as type' option. I can specify a default path which includes an extension, but this doesn't populate 'Save as type'. I'm using the Windows native file dialog. Python. Example code:

    @f_qt = QtGui.QFileDialog.getSaveFileName(self, 'Save', default_path) @

    The closest I could find is the defaultSuffix property of QFileDialog, but this doesn't appear to be what I'm looking for. I'd like to be able to specify one or more file types the user can save as, as is standard with this type of dialog. Currently, it's showing only 'All files(.)'.


  • Moderators

    I don;t know if it works the same in python, but please take a look at "the documentation": Notice the filter parameter.

  • Thank you - that worked.

    Example code using this:
    @f_qt = QtGui.QFileDialog.getSaveFileName(self, 'Save', default_path, filter='*.pdf')@

    Tangental - in general, I wish the docs would include plain English explanations of what each property/function etc does.

Log in to reply