[PyQt] User selected filter in QFileDialog

barmanoo olivier.friard at gmail.com
Tue Jun 30 16:36:04 BST 2009

Phil Thompson-5 wrote:
> getSaveFileName() is a static method that creates its own dialog. In other
> words the dialog the user is using isn't the same one you have created.
> selected_filter = QString()
> projectFileName = QFileDialog.getSaveFileName(self, 'Save the current
> project', '',
>         'your;;filters', selected_filter)
> selected_filter will be updated with the selected filter (a horribly
> unpythonic API).
> Phil

Thank you for your reply.
Unfortunately your suggestion do not fixed my problem...

I modified my code to:

self.projectFileName=QFileDialog.getSaveFileName(self,'Save the current
AnnHyb project','','pyAnnHyb project (*.pyannhyb);;AnnHyb project
(*.annhyb);;All files (*)',filter)
print str(filter)

The filter QString variable is now always empty and no more "All files (*)" 

I am using Python 2.6.2, Qt 4.5.0 and PyQt 4.4.4 on Linux

The full code is available at
(file: pyannhyb.py , line 915)

Thank you
View this message in context: http://www.nabble.com/User-selected-filter-in-QFileDialog-tp24270454p24274183.html
Sent from the PyQt mailing list archive at Nabble.com.

More information about the PyQt mailing list