PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 819 - QFileDialog.getSaveFileName does not accept a 'selectedFilter' argument.
: QFileDialog.getSaveFileName does not accept a 'selectedFilter' argument.
Status: CLOSED FIXED
Product: PySide
Classification: Unclassified
Component: QtGui
: 1.0.1
: All All
: P3 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2011-04-08 11:16 EEST by Gerald
Modified: 2011-04-29 18:06 EEST (History)
9 users (show)

See Also:


Attachments
Resolving the bug (799 bytes, text/plain)
2011-04-18 07:16 EEST, Mailson Lira
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald 2011-04-08 11:16:48 EEST
Both the Qt docs and PyQt docs list a selectedFilter argument for
getSaveFileName.  (Ref:
http://doc.qt.nokia.com/4.7/qfiledialog.html#getSaveFileName)

Oddly enough the error message one gets when trying specify a selectedFitler
argument indicates that it should be supported although it is not listed in the
documentation.

This code runs without error using PyQt but throws an error on the second
dialog in PySide:

import sys
from PySide import QtGui,QtCore

app = QtGui.QApplication(sys.argv)

filters = ["Text files (*.txt)","All files (*.*)"]
selectedFilter = filters[1]
filters = ';;'.join(filters)

test = QtGui.QFileDialog.getSaveFileName(None,'test','',filters)
test2 =
QtGui.QFileDialog.getSaveFileName(None,'test','',filters,selectedFilter)

app.exec_()
sys.exit()
Comment 1 Gerald 2011-04-08 12:05:30 EEST
Just so that we are clear.  I realise that the selected filter is returned in a
tuple but there is currently no way to set the default filter if it isn't also
accepted as an argument.
Comment 2 Hugo Parente Lima 2011-04-11 15:22:49 EEST
Don't worry I got the point :-)
Comment 3 Mailson Lira 2011-04-18 07:16:19 EEST
Created attachment 312 [details]
Resolving the bug

I'm attaching a patch proposal.
It allows the user to pass the selectedFilter argument. Unfortunately, it won't
work as expected since there's a bug on Qt itself.

I tried the following code on Qt/C++ and the "Image files (*.png)" filter
wasn't the default filter when the File Dialog opened.
QString selectedFilter = tr("Image files (*.png)");
QString fileName = QFileDialog::getSaveFileName(this, "test", "", tr("All files
(*.*);;Text files (*.txt);;Image files (*.png)"), &selectedFilter);

Note: I proposed to a PySide project on Google Summer of Code 2011 and found
this bug while trying to contribute with a bug fix to PySide project (as
required by the organization)

GSoC link_id: mailson
Comment 4 Hugo Parente Lima 2011-04-19 20:32:02 EEST
*** Bug 832 has been marked as a duplicate of this bug. ***
Comment 5 renato filho 2011-04-29 00:03:37 EEST
fixed on pyside commit:

commit d34e1541900d777d195e2f9c0c5049b2c0018cb2
Author: Renato Filho <renato.filho@openbossa.org>
Date:   Thu Apr 28 14:50:25 2011 -030
Comment 6 renato filho 2011-04-29 18:06:19 EEST
PySide release 1.0.2