[Qt-creator] QDir::currentPath() different when run from QtCreator?

Eike Ziller eike.ziller at nokia.com
Tue Jun 16 11:37:57 CEST 2009


Hi,

On Jun 15, 2009, at 8:44 PM, ext Liam Staskawicz wrote:

> Hiya - I'm finding that when I run my app on OS X from within  
> QtCreator, the QDir::currentPath() is set as the path of the  
> executable all the way down in the application bundle (myproject.app/ 
> Contents/MacOS/myproject) whereas when the project is run normally  
> (just double clicked) the currentPath() is set to the top level  
> bundle location.
>
> Is it recommended to simply make some affordances in my code to  
> account for whether it's being run in QtCreator, or is there some  
> other way to resolve this?

You can set the working directory (i.e. currentPath()) to use when  
running from Qt Creator in the Projects mode, Run Settings, Working  
Directory. But it might be even better to avoid usage of  
QDir::currentPath() in your situation completely, e.g. by using  
QCoreApplication::applicationDirPath(), which always points to  
myproject.app/Contents/MacOS, so you can be sure that  
QCoreApplication::applicationDirPath() + "/../../.." points to the  
location where the app bundle is located.

Regards, Eike

-- 
Eike Ziller
Software Engineer
Nokia, Qt Software
Phone  +49 (0)30 6392 3255
Fax    +49 (0)30 6392 3256
E-mail eike.ziller at nokia.com







More information about the Qt-creator-old mailing list