Solved Get CurrentPath String
-
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 -
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.
-
@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?
-
@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 youcd
to where you want the current directory to be before you run your executable, you will get that path fromQDir::currentPath()
. -
@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 ?
-
@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?
-
@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 ? -
@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 -
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.
-
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 :-)
-
Ok i gonna look that, thx for your time