Home > Mobile >  Qt relative path to open the file
Qt relative path to open the file

Time:09-26

I want to open exe directory upper directory another subdirectory folder inside of a file, but can you tell me how to open, thanks for the great god

CodePudding user response:

QT current folder seems to be in an exe file directory, so your path should be ".. XXX_ folder/XXX_ filename

CodePudding user response:

./subdir/file

CodePudding user response:

Or you can temporarily use absolute paths

CodePudding user response:

. \ acb \ test. TXT

CodePudding user response:

Hello, I use a relative path to open has been failed, such as case1, 2; Use absolute paths can be, however, such as case3
Case 1: f.o pen (" QDir: : currentPath ()/prog1. Yukio okamoto, "); break;
Case 2: f.o pen ("./prog2. Yukio okamoto, "); break;
Case 3: f.o pen (" D:/Qt_work/pj3/prog3. Yukio okamoto, "); break;
I f is used the fstream, prog files and my CPP, pro of what are in the same directory,
consult

CodePudding user response:

reference 5 floor ZJDZ reply:
hello, I use a relative path to open has been failed, such as case1, 2; Use absolute paths can be, however, such as case3
Case 1: f.o pen (" QDir: : currentPath ()/prog1. Yukio okamoto, "); break;
Case 2: f.o pen ("./prog2. Yukio okamoto, "); break;
Case 3: f.o pen (" D:/Qt_work/pj3/prog3. Yukio okamoto, "); break;
I f is used the fstream, prog files and my CPP, pro of what are in the same directory,
Consult

Relative paths, it is under you release or debug, try put the files in there

CodePudding user response:

If it is QtCreator build running, generates a build - XXX - XXX/directory, a directory with the debug release two folders, exe in one, the program at this time of the current path is build/rather than build - XXX - XXX - XXX - XXX/release

The first QDir: : CurrentPath () writes a string, it is a string, should
QString Path=XX: : CurrentPath + "/prog1. Yukio okamoto,";
F.o pen (Path) toLatin1) data ());

The second is the first, do you think of the current path and run at this time of the current path may not be a,
  •  Tags:  
  • Qt
  • Related