Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    How can we get the current working directory path ?

    General and Desktop
    4
    6
    9200
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pratik041 last edited by

      I have tried
      @QDir::currentpath()@
      but here i am getting the path of current application directory. I want to get path of current working project.

      Pratik Agrawal

      1 Reply Last reply Reply Quote 0
      • S
        Scylla last edited by

        Please define "current working project", I don't know what you mean.

        1 Reply Last reply Reply Quote 0
        • P
          pratik041 last edited by

          [quote author="Scylla" date="1331707050"]Please define "current working project", I don't know what you mean.[/quote]

          Suppose the project i am currently running under Qt is "mainwindow". The mainwindow project is present in path "C:/Documents and setting/ Desktop / mainwindow". So i want to get this path.While i am using QDir::currentpath() i am getting "C:/Documents and setting/ Desktop /mainwindow/mainwindow.app/Contents/MacOS" as current path in MAC for that project. which is actually the application path not the current project path. So how could i get the only project path?

          Pratik Agrawal

          1 Reply Last reply Reply Quote 0
          • L
            lgeyer last edited by

            I don't think this is possible without passing any additional information, as the resulting binary has no information about the origin project structure.
            @
            // .pro

            DEFINES += PROJECT_PATH="\"$$PWD\""
            DEFINES += BUILD_PATH="\"$$OUT_PWD\""

            // .cpp

            QString projectPath(PROJECT_PATH);
            QString buildPath(BUILD_PATH);
            @

            1 Reply Last reply Reply Quote 0
            • P
              pratik041 last edited by

              [quote author="Lukas Geyer" date="1331710589"]I don't think this is possible without passing any additional information, as the resulting binary has no information about the origin project structure.
              @
              // .pro

              DEFINES += PROJECT_PATH="\"$$PWD\""
              DEFINES += BUILD_PATH="\"$$OUT_PWD\""

              // .cpp

              QString projectPath(PROJECT_PATH);
              QString buildPath(BUILD_PATH);
              @[/quote]
              thanks, this i was trying to get.

              Pratik Agrawal

              1 Reply Last reply Reply Quote 0
              • A
                andre last edited by

                Note that this is then hard coded into your binairy at compile time. Not sure if that is what you expect when you distribute your application...

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post