[Qt-interest] Force file extension with QFileDialog::getSaveFileName?

Constantin Makshin cmakshin at gmail.com
Wed Jun 22 18:37:21 CEST 2011


I totally agree changing file extensions (at least, without asking the user) is a very bad idea. But that's how I understood original David's question ("ensure the result of this dialog ends with one of the valid extensions specified by the filter") — if the user doesn't specify any extension or specifies "invalid" one, enforce using one of "valid" values. Probably David wasn't clear enough and I misunderstood his message...

On Tuesday, June 21, 2011 11:13:26 PM Atlant Schmidt wrote:
> Constantin:
> 
> > "Brute force" method - if the user specifies incorrect
> > extension (e.g., enters "foo.exe" into the file name
> > box when saving a picture), replace it or simply append
> > a valid one when opening the file.
> 
>   It's a *HUGE* violation of Human Interface Design
>   Principles to do something like this. Reject an
>   extension/filetype if you don't like it, but don't
>   you dare change it behind the user's back to suit
>   your needs. That would certainly violate the principle
>   of "least surprise" and on some systems, might end up
>   with the user confused about why, having typed "foo.ppm",
>   the program is now asking them if they want to over-write
>   the exitsing "foo.bmp". (Or even worse yet, maybe the
>   program simply silently over-writes their existing .bmp
>   file with new contents; that loss-of-data accident could
>   spell a lawsuit!)
> 
>                               Atlant
> 
> 
> -----Original Message-----
> From: qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com [mailto:qt-interest-bounces+aschmidt=dekaresearch.com at qt.nokia.com] On Behalf Of Constantin Makshin
> Sent: Tuesday, June 21, 2011 11:51
> To: Qt Interest
> Subject: Re: [Qt-interest] Force file extension with QFileDialog::getSaveFileName?
> 
> "Brute force" method - if the user specifies incorrect extension (e.g., enters "foo.exe" into the file name box when saving a picture), replace it or simply append a valid one when opening the file.
> 
> On Tuesday, June 21, 2011 07:40:47 PM David Doria wrote:
> > When I use QFileDialog::getSaveFileName, it allows the user to type
> > any file name. What I would like to do is ensure the result of this
> > dialog ends with one of the valid extensions specified by the filter
> > (*.png *.bmp - etc). Is there an option for this?
> >
> > Thanks,
> >
> > David
> 
> This e-mail and the information, including any attachments, it contains are intended to be a confidential communication only to the person or entity to whom it is addressed and may contain information that is privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender and destroy the original message.
> 
> Thank you.
> 
> Please consider the environment before printing this email.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110622/47b482b9/attachment.bin 


More information about the Qt-interest-old mailing list