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

Atlant Schmidt aschmidt at dekaresearch.com
Tue Jun 21 21:13:26 CEST 2011


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.



More information about the Qt-interest-old mailing list