Qt-interest Archive, November 2007
QFileDialog:: getSaveDirectoryName?
Message 1 in thread
Hi,
I am currently working on a project where I want to prompt the user
for a name of a directory where I should save some files.
Today I use QFileDialog:: getSaveFileName to get a filename and then
I make a directory with that name instead of a file.
This approach have the following flaws:
1.The user can not choose an existing directory to save as (unless he
types in a exisiting name manually).
2.If the user manually types in the name of an existing directory
(but leaves out the ending, which automatically will be added by my
code if it is missing), then he can overwrite an existing directory,
but without warning.
3.If the user types in the name of an existing directory (even adding
the correct ending) he will not be able to save because the
filedialog will report that "The name "name.dir" is already used by a
folder.".
4.There is no way to filter directories so that only the ones with
the correct ending is visible.
I have thought about several other ways to solve this problem but
they do not meet my requirements:
a. I realize that I could use QFileDialog::getExistingDirectory to
get exising directories, but this would not give me the option to
create new ones and it still would not give me any way to filter.
b. I do not want to have two different save options (one for saving
with a new name and one for choosing an existing directory), this
would not give me the option to filter.
c.I do not want to force the user to use the make new directory
button in the filedialog, because I do not see how this is intuitive
for a user that just wants to save.
I want a (directory)dialog with the following properties (much like
getSaveFileName for files):
1.Only directories should be visible
2.A filter should enable only directories with the correct ending to
be visible, i.e. (*.dir)
3.Get a dialog asking if you want to overwrite if you have selected
an exisiting directory
4.Allows you to type in a new directory name
Anyone got a good suggestion on how to solve my problem?
-Janne Beate Bakeng,
Sintef Health Research
--
[ signature omitted ]
Message 2 in thread
Janne Beate Lervik Bakeng wrote:
> Hi,
Hi.
> I want a (directory)dialog with the following properties (much like
> getSaveFileName for files):
> 1.Only directories should be visible
> 2.A filter should enable only directories with the correct ending to be
> visible, i.e. (*.dir)
> 3.Get a dialog asking if you want to overwrite if you have selected an
> exisiting directory
> 4.Allows you to type in a new directory name
>
> Anyone got a good suggestion on how to solve my problem?
When I wrote an application that required a very specialized directory /
file dialog, I simply designed the dialog myself, subclassed QDirModel,
and attached that to a QTreeView shown in the dialog. Then I connected
the selection in the QTreeView to a slot in a QLineEdit, and vice versa.
Depending on how specialized this dialog is, there are possibly easier
ways. However, it's somewhere to start.
Darrik
--
[ signature omitted ]
Message 3 in thread
Hi again.
It seems to be my best option yes. Too bad there isn´t a function
called QFileDialog:: getSaveDirectoryName.
-Janne Beate Bakeng,
Sintef Health Research
Den 5. nov. 2007 kl. 20.09 skrev Darrik Mazey:
> Janne Beate Lervik Bakeng wrote:
>> Hi,
>
> Hi.
>
>> I want a (directory)dialog with the following properties (much
>> like getSaveFileName for files):
>> 1.Only directories should be visible
>> 2.A filter should enable only directories with the correct ending
>> to be visible, i.e. (*.dir)
>> 3.Get a dialog asking if you want to overwrite if you have
>> selected an exisiting directory
>> 4.Allows you to type in a new directory name
>> Anyone got a good suggestion on how to solve my problem?
>
> When I wrote an application that required a very specialized
> directory / file dialog, I simply designed the dialog myself,
> subclassed QDirModel, and attached that to a QTreeView shown in the
> dialog. Then I connected the selection in the QTreeView to a slot
> in a QLineEdit, and vice versa.
>
> Depending on how specialized this dialog is, there are possibly
> easier ways. However, it's somewhere to start.
>
> Darrik
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx
> with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
--
[ signature omitted ]