0

I just started using QTCreator IDE on Linux, and I love everything about it except I ran into an issue with file IO. This doesn't concern the QT library, just the IDE and C++. The issue is that I have to specify the full path name for a file - like so:

Shader shader ("/home/user/Documents/OpenGL/SandboxProject/vertexShader.glsl")

In contrast, on CodeBlocks I can just do the current directory:

Shader shader ("./vertexShader.glsl")

Do I need to configure something in the IDE? I noticed that when I type in the terminal which qtcreator it is in /usr/bin/ whereas my CodeBlocks binary is in /usr/local/bin/

BlazePascal
  • 391
  • 5
  • 12
  • Generally speaking, it's *wrong* to depend on the current working directory of your process. When your user will start your application, the working directory can be *anything*, unless it's a console application. You need to reference the file in the application directory, and you need to deploy it along with the executable from your project file. [This answer](http://stackoverflow.com/a/26490841/1329652) details it for OS X, you'd do it similarly for Windows. – Kuba hasn't forgotten Monica Mar 07 '15 at 22:07

1 Answers1

2

Go to Projects -> Select your project tab -> Select the Run tab -> Check the Run section and set the Working directory as you need it.

If you are developing a cross-platform Qt app, I'd recommend to use the Qt Resource System, which compiles resource files into your binary.

Simon Warta
  • 10,850
  • 5
  • 40
  • 78