[Qt-interest] Problem with selecting a directory
Ferenc Stelcz
ferenc at stelcz.hu
Mon Apr 20 08:04:07 CEST 2009
Nouman Khalid wrote:
> Hi all,
>
> I want to select a directory where my application where perform other
> functions. I know how to set directory with the help of
>
> QDir::setCurrent ( const QString & path )
>
> but i don't want user to remember the path to enter. I want a dialogue box
> to open (when user may click on say 'Select directory' button) from where he
> can browse through the filesystem to finally select a directory or even to
> make a new directory and then selecting that newly made directory as target.
>
> Any idea?
>
> Thanks
> Nomi
>
Try this:
QString dir =
QFileDialog::getExistingDirectory(
this,
tr("Open Directory"),
"/home",
QFileDialog::ShowDirsOnly);
This pops-up a file dialog where you can select (any _existing_)
directories just as you would from any other application. Then you can
pass *dir* to setCurrent() or do with it whatever you like! HTH
--
Ferenc Stelcz
Junior Software Engineer
Banyan Technologies LLC.
__________ Information from ESET Smart Security, version of virus signature database 4020 (20090420) __________
The message was checked by ESET Smart Security.
http://www.eset.com
More information about the Qt-interest-old
mailing list