Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can we get the current working directory path ?
QtWS25 Last Chance

How can we get the current working directory path ?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 4 Posters 9.6k Views
  • 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 Offline
    P Offline
    pratik041
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      Scylla
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pratik041
        wrote on last edited by
        #3

        [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
        0
        • L Offline
          L Offline
          lgeyer
          wrote on last edited by
          #4

          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
          0
          • P Offline
            P Offline
            pratik041
            wrote on last edited by
            #5

            [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
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              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
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved