[PyQt] Bug in QFileDialog

Hans-Peter Jansen hpj at urpla.net
Wed Dec 8 22:10:57 GMT 2010


On Wednesday 08 December 2010, 22:42:45 Hans-Peter Jansen wrote:
> On Wednesday 08 December 2010, 20:24:16 Vicent Mas wrote:
> > On 2010-12-08 "Hans-Peter Jansen" <hpj at urpla.net> said:
> > > On Friday 03 December 2010, 11:12:42 Vicent Mas wrote:
> > > > Hi,
> > > >
> > > > the attached script shows a bug in QFileDialog. If on a given
> > > > dialog you call setLabelText(QFileDialog.Accept, text) and then
> > > > you call setFileMode(FileMode) then the label is not set and
> > > > the default label is used. If you call setFileMode(FileMode)
> > > > first and then you call setLabelText(QFileDialog.Accept, text)
> > > > then the label is set.
> > > >
> > > > As you can see in the script the problem only happens with the
> > > > QFileDialog.Accept constant. Other QFileDialog.DialogLabel
> > > > constants work fine.
> > > >
> > > > I don't know if it is a Qt bug or a PyQt one. Neither I know if
> > > > the problem is in the setLabelText method or in th setFileMode
> > > > one.
> > >
> > > Confirmed with:
> > > python: 2.6
> > > sip: 4.12-snapshot-b202f0d04ba6
> > > qt4: 4.7.1
> > > pyqt4: snapshot-4.8.2-e73d5045bea5
> > >
> > > This script is simple enough to do a C++ version, as I doubt that
> > > this is a PyQt issue. Then, you need that version anyway to
> > > report this to Nokia. ;-)
> > >
> > > Pete
> >
> > Thanks for your answer Pete.
> >
> > I've never written in C++. I suppose this is a good time for
> > starting
> >
> > :D
>
> It's awful, when you're used to python, but it's doable.
>
> Luckyly Antonio posted a link with exactly what you need as a
> starting base.. Call back, if you're stuck.

Vicent, bad luck: check the fileMode paragraph a couple of lines below:

http://doc.trolltech.com/latest/qfiledialog.html#FileMode-enum

This function will set the labels for the FileName and Accept 
DialogLabels. It is possible to set custom text after the call to 
setFileMode().

Pete


More information about the PyQt mailing list