Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6595563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:57:21+00:00 2026-05-25T17:57:21+00:00

About pyQt4 I prefer to use the static method for the getSaveFilename in the

  • 0

About pyQt4

I prefer to use the static method for the getSaveFilename in the QFileDialog so that the user sees the Windows/Mac native dialog.

My problem is that if the user doesn’t type the file extension the in the save file name (say when selecting an image type to save a file as), then I don’t have a way of checking to see what type of file they wanted to save as.

How can I create a dialog to save files with a filter, and how to know which filter the user chose?

For example:

files_types = "GML (*.gml);;Pickle (*.pickle);;YAML (*.yml)"
file = QtGui.QFileDialog.getSaveFileName(self, 'Save file', '', files_types)

With var file I’ll have only the file’s path, but I’m not sure whats the format that user chose.

So, I wanna know how could I get the extension, or the files type chosen by user.
Is there away to get the selectedFilter using this method?

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:57:22+00:00Added an answer on May 25, 2026 at 5:57 pm

    You can use the getSaveFileNameAndFilter() method:

    filename, filter = QtGui.QFileDialog.getSaveFileNameAndFilter(self, 'Save file', '', files_types)
    

    (In PySide however, getSaveFileNameAndFilter() does not exist, and getSaveFileName() already behaves that way. I’m not sure whether this is also the case for PyQT api version 2, which is the default for Python 3)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm porting a PyQt4 (PySide) application that I wrote for Linux and Windows to
About 2 years ago I dropped windows from my home PC and switched 100%
I have a Python application (with GUI, using PyQt4) that gets spawned by the
I'm looking for some information about the roll-out of a python project that uses
about foreach, why it doesnt accept the AND logical operator? I've already use the
How do i go about adding Chaco to an existing PyQt4 application? Hours of
I'm looking for a GUI toolkit/framework to create applications that run on Mac Snow
I need to integrate an editor into a window/dialog in my PyQt4 application. It
I'm writing a small app (learning Python and PyQt) that has an About box.
About every 3rd time my app serves a particular update action (two that I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.