×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2013
    Posts
    2

    How to get current working directory in a Qt application?

    I’m writing a program in C++ using the Qt library. I would like to get current working directory of my program (I mean that is the absolute path which contains file *.pro). I saw the QDir::currentPath() function, but it gives back the directory where the binary is.



    Does anyone has any solutions?

    Thank you,
    Lee.

    P/S: I have uploaded the image which describes the path that I want to get.
    Last edited by LeeMinh; 2013-07-15 at 03:36.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to get current working directory in a Qt application?

    the application itself does not really care of the pro file, its used only in the IDE for managing the project, thus what would you want to do with it in the application itself ?

  3. #3
    Registered User
    Join Date
    Jul 2013
    Posts
    2

    Re: How to get current working directory in a Qt application?

    Hi symbianyucca,

    I have uploaded the image which describes the path I want to get. Do you have any suggestions?

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: How to get current working directory in a Qt application?

    You propably should check where you did upload the file into, I would suggest checking the docs of the API used and seeing what kind of path it uses for storing the files, and whetehr you can change it. Anyway, its newer likely to be the folder where your project pro file is located at.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: How to get current working directory in a Qt application?

    Quote Originally Posted by LeeMinh View Post
    I would like to get current working directory of my program (I mean that is the absolute path which contains file *.pro). I saw the QDir::currentPath() function, but it gives back the directory where the binary is.
    Probably because that is the current working directory of your program. Just it is not c:\Qt\...\Demo. If you are running the code from QtCreator, you can set the working directory, look for something like http://qt-project.org/doc/qtcreator-...-settings.html.

Similar Threads

  1. how to create a txt file in current working directroy?
    By fengwujiutian in forum Mobile Java General
    Replies: 1
    Last Post: 2010-03-04, 11:59
  2. How to refer to a file in current directory
    By ali.sajjad in forum Symbian
    Replies: 1
    Last Post: 2009-08-03, 12:27
  3. read a file in current directory of program
    By manish.garg in forum Symbian
    Replies: 9
    Last Post: 2008-11-18, 10:12
  4. Working directory of .jar
    By magnetic in forum Mobile Java General
    Replies: 6
    Last Post: 2007-01-15, 10:43
  5. Current Tool Installers Not Working, why?
    By badappleFG in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2003-02-28, 16:55

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×