[Qt-interest] Force file extension with QFileDialog::getSaveFileName?
Eric Clark
eclark at ara.com
Tue Jun 21 23:15:01 CEST 2011
> -----Original Message-----
> From: David Doria [mailto:daviddoria at gmail.com]
> Sent: Tuesday, June 21, 2011 4:05 PM
> To: Eric Clark
> Cc: Qt Interest (qt-interest at trolltech.com)
> Subject: Re: [Qt-interest] Force file extension with
> QFileDialog::getSaveFileName?
>
> On Tue, Jun 21, 2011 at 4:59 PM, Eric Clark <eclark at ara.com> wrote:
> >
> >
> >> -----Original Message-----
> >> From: David Doria [mailto:daviddoria at gmail.com]
> >> Sent: Tuesday, June 21, 2011 3:56 PM
> >> To: Eric Clark
> >> Cc: Qt Interest (qt-interest at trolltech.com)
> >> Subject: Re: [Qt-interest] Force file extension with
> >> QFileDialog::getSaveFileName?
> >>
> >> On Tue, Jun 21, 2011 at 4:47 PM, Eric Clark <eclark at ara.com> wrote:
> >> > I am not real sure why it is not working, but maybe I am not
> >> > telling you the
> >> right thing to do. I have never tested the setDefaultSuffix function
> >> out, so I was just giving you what I thought it was supposed to do.
> >> We do not use this function, instead we just add the extension if it
> >> is not there like I suggested you would have to do with the static
> >> function. I am guessing you will have to do the same thing. Here is an
> example of what to do:
> >> >
> >> > QString fileName = QFileDialog::getSaveFileName(...);
> >> > QFileInfo file(filename);
> >> > if(file.suffix().isEmpty()) fileName += ".txt";
> >> >
> >> > This example does not look at the selected extension. So, you may
> >> > want to
> >> pass in a parameter for the selected extension and use the one the
> >> user had selected when they selected the file instead of just choosing
> one.
> >> >
> >> > Sorry the other stuff did not work :(
> >> >
> >> > Eric
> >>
> >> That method works fine, thanks. However, since we both expected the
> >> same thing from the defaultSuffix, we should probably alert the devs
> >> so they can clarify the documentation, don't you think?
> >
> > Yes, you are probably right. Especially since the documentation clearly says
> it should. Here is the sentence taken directly from the docs if you want to
> include it in your bug report:
> >
> > "This property specifies a string that will be added to the filename if it has
> no suffix already."
> >
> > Eric
>
> I don't understand the first comment. Are they saying they will not change
> this and it doesn't work like we're expecting on Linux (I am on Linux)?
I am not real sure this is exactly what you are looking at. They are saying that under Windows, the automatic file extensioning is done by default for you and that on Linux you have to do what you just did. However, I do not see any mention of the setDefaultSuffix function. I would still go ahead and start a new ticket since they do not mention the defaultSuffix in this report. But that is just my opinion...
Eric
>
> http://bugreports.qt.nokia.com/browse/QTBUG-11352
>
> David
More information about the Qt-interest-old
mailing list