Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, October 2006
Re: QFileDialog and My Documents


Message 1 in thread

On Thursday 21 September 2006 23:25, Derrick Johnson wrote:
> I'm having a brain freeze here...How do you get QFileDialog to open into
> the directory set for the My Documents folder in Windows?  Assuming I don't
> know the path to put into:
>
>     fileName = QFileDialog::getOpenFileName(this, caption, directory, ...)
>
> How do I find out the path for the My Documents folder to be able to
> initiate the Open File dialog and default to this path?
>
> Thanks,
> -D

Qt doesn't currently provide a way to get that value, but you can get it out 
of the registry easily enough using QSettings.
    
    QSettings settings(QSettings::UserScope, "Microsoft", "Windows");
    settings.beginGroup("CurrentVersion/Explorer/Shell Folders");
    return settings.value("Personal").toString();

-Benjamin Meyer

--
 [ signature omitted ]