QFileDialog with default directory

c++, cross-platform, qt, qt4, user-interface

Solution

Use `QDir::home()`, and then `QDir::cdUp()` to go up one.

Problem

How to create cross platform `QFileDialog` with default directory? I have a code like ``` QFileDialog::getSaveFileName(this,"Save File","/home",tr("Any File (*.*);;Text file (*.txt);;Compressed file (*.zip *.tar *.rar);;Image (*.png *.xpm *.jpg *.tiff)")) ``` This works fine with Linux. But in windows the users directory will be `"C:\Users"`. I don't know in Mac. I need this dialogue with default directory as user folder. How to do that? I saw the `toNativeSeparators()` but this need more line of codes. Is there any easiest way to do that?

Original source