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. Get CurrentPath String
Forum Updated to NodeBB v4.3 + New Features

Get CurrentPath String

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 5 Posters 770 Views 2 Watching
  • 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.
  • E Offline
    E Offline
    ErikC
    wrote on last edited by
    #1

    Hey ,
    I cannot recover the address without the suffix "build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug\debug"
    I read the doc and even using the functions "QCoreApplication::applicationDirPath()" and "QDir::currentPath()"
    I get the path suffix ...
    Someone would have the solution please ?
    thx

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #8

      The icon should be added to a resource file, not in some arbitrary path somewhere on your harddisk which will change as soon as you install your program.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      5
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #2

        @ErikC said in Get CurrentPath String:

        I get the path suffix ...

        Can you explain a little bit more what you get and what you want to achieve?

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        E 1 Reply Last reply
        0
        • E ErikC

          Hey ,
          I cannot recover the address without the suffix "build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug\debug"
          I read the doc and even using the functions "QCoreApplication::applicationDirPath()" and "QDir::currentPath()"
          I get the path suffix ...
          Someone would have the solution please ?
          thx

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #3

          @ErikC
          QCoreApplication::applicationDirPath() will have what you show at the end because that is where the executable you are running is located. QDir::currentPath() will also have that if you run the executable while your current directory (e.g. from a command-line, or from a shortcut icon depending on your settings for that) is sitting there too. If you cd to where you want the current directory to be before you run your executable, you will get that path from QDir::currentPath().

          1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            @ErikC said in Get CurrentPath String:

            I get the path suffix ...

            Can you explain a little bit more what you get and what you want to achieve?

            E Offline
            E Offline
            ErikC
            wrote on last edited by
            #4

            @Christian-Ehrlicher Thx for your time,
            I have :

            • "C:/Users/erikc/Documents/MyApp/build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug" with QDir::currentPath()
            • "C:/Users/erikc/Documents/MyApp/build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug/debug" with QCoreApplication::applicationDirPath()

            And i want get "C:/Users/erikc/Documents/MyApp/" in QString .

            @JonB Ok thx so i need to change my running command in project settings or something like that ?

            SGaistS 1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @ErikC said in Get CurrentPath String:

              And i want get "C:/Users/erikc/Documents/MyApp/" in QString .

              This is a completely unrelated directory - why do you need it?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              E 1 Reply Last reply
              2
              • E ErikC

                @Christian-Ehrlicher Thx for your time,
                I have :

                • "C:/Users/erikc/Documents/MyApp/build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug" with QDir::currentPath()
                • "C:/Users/erikc/Documents/MyApp/build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug/debug" with QCoreApplication::applicationDirPath()

                And i want get "C:/Users/erikc/Documents/MyApp/" in QString .

                @JonB Ok thx so i need to change my running command in project settings or something like that ?

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #6

                @ErikC said in Get CurrentPath String:

                And i want get "C:/Users/erikc/Documents/MyApp/" in QString .

                Hi,

                That's likely where your application sources are located, correct ?
                What do you need there ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • Christian EhrlicherC Christian Ehrlicher

                  @ErikC said in Get CurrentPath String:

                  And i want get "C:/Users/erikc/Documents/MyApp/" in QString .

                  This is a completely unrelated directory - why do you need it?

                  E Offline
                  E Offline
                  ErikC
                  wrote on last edited by
                  #7

                  @Christian-Ehrlicher it's the location of my project, i just want to do"C: / Users / erikc / Documents / MyApp /" + "/MyIconName.png" to change the window icon but when i do that with QDir :: currentPath () i obtain "C: / Users / erikc / Documents / MyApp / build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug / MyIconName.png"
                  but the location file is : "C: / Users / erikc / Documents / MyApp / MyIconName.png".
                  So i need to delete this 'suffix' : "build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug" to get icon location in all circumstances

                  Pl45m4P 1 Reply Last reply
                  0
                  • Christian EhrlicherC Offline
                    Christian EhrlicherC Offline
                    Christian Ehrlicher
                    Lifetime Qt Champion
                    wrote on last edited by
                    #8

                    The icon should be added to a resource file, not in some arbitrary path somewhere on your harddisk which will change as soon as you install your program.

                    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                    Visit the Qt Academy at https://academy.qt.io/catalog

                    1 Reply Last reply
                    5
                    • E ErikC

                      @Christian-Ehrlicher it's the location of my project, i just want to do"C: / Users / erikc / Documents / MyApp /" + "/MyIconName.png" to change the window icon but when i do that with QDir :: currentPath () i obtain "C: / Users / erikc / Documents / MyApp / build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug / MyIconName.png"
                      but the location file is : "C: / Users / erikc / Documents / MyApp / MyIconName.png".
                      So i need to delete this 'suffix' : "build-MyApp-Desktop_Qt_5_13_2_MinGW_32_bit-Debug" to get icon location in all circumstances

                      Pl45m4P Online
                      Pl45m4P Online
                      Pl45m4
                      wrote on last edited by Pl45m4
                      #9

                      @ErikC

                      To switch between existing icon images, it is better to create an image resource and just exchange the names (resource paths). Then you also dont have problems with the path anymore

                      Edit: Damn @Christian-Ehrlicher was faster :-)


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      1 Reply Last reply
                      4
                      • E Offline
                        E Offline
                        ErikC
                        wrote on last edited by
                        #10

                        Ok i gonna look that, thx for your time

                        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