[Qt-interest] QFileDialog defaultSuffix
John Cummings
jcummings2 at users.sf.net
Wed Feb 10 16:39:06 CET 2010
To answer my own message. I believe this issue is an artifact of the
interaction between the QListView and the QLineEdit.
I believe what happens in my example is the following:
1. Typing "filedialog" into the "File name" QLineEdit causes the
existing "filedialog" file to be selected in the QListView.
2. When checking the file name, the selection in QListView implies that
the default suffix does not need to be added, even though there is no
suffix for this file and there currently is not a default suffix.
3. Setting the defaultSuffix does not change the selection in the QListView.
4 and 5. When checking the file name again, the selection in QListView
is still used, which apparently means that the defaultSuffix is not used.
6. Editing the file name in the QLineEdit clears the QListView selection
and thus invokes the defaultSuffix logic again.
So, on one hand this seems like a bug. On the other hand, if I actually
click on the file myself in the QListView, then I may not expect the
default suffix to be used. Is that behavior confusing to anyone else or
have I created a false problem?
Thank you
John Cummings
John Cummings wrote:
> I am trying to use the defaultSuffix feature of QFileDialog while
> choosing a file to save. I have come across a bug or feature that I am
> unsure how to overcome. I have attached a small (less than 60 lines)
> example that demonstrates the problem. I would be glad to submit a bug
> unless someone tells me what I am missing. I have tried both Qt 4.4.x
> and Qt 4.6.0 on Linux.
>
> In the attached example, the added "QLineEdit" below the main
> QFileDialog area is connected to a slot that sets the defaultSuffix.
> However, it appears that even though I set the defaultSuffix after I
> have typed in a file name, the defaultSuffix is not used to check for
> the existence of a file. More generally, the defaultSuffix is not used
> in the selectedFiles() method if it is updated after the file name has
> been entered. So, to re-create the alleged bug with the attached
> example, do the following from the source directory (note, I assume the
> executable name is filedialog, which is not right on Windows):
>
> 1. Type "filedialog" into the "File name" line edit and click "Save."
> 2. You are correctly prompted to confirm the overwrite of the
> "filedialog" file.
> 3. Type "pro" into the unlabeled QLineEdit at the bottom of the dialog.
> 4. Click "Save"
> 5. You are incorrectly prompted to confirm the overwrite of the
> "filedialog" file. You really should be prompted about the
> "filedialog.pro" file existing.
> 6. Until you change the "File name" line edit, the unlabeled QLineEdit
> will not have any effect.
>
> So, may question is, have I missed something? Is there an update() type
> call (I've tried update in this case and it doesn't help) that I need to
> make?
>
> Thank you
> John Cummings
>
>
>
More information about the Qt-interest-old
mailing list