Path Query in QT
-
With QT I'm Using Python Embedding . In QT my project folder I kept one file there. So without using absolute path and Passing Full path I just want Read the python file by Python file name( as Relative Path) so while creating EXE can run in any system.
Please help me, its very urgent
pythonFile=PyImport_ImportModule("DistanceEstimation");
["Distance Estimation is python file"]
This requirement is for creating EXE purpose] -
@AArju said in Path Query in QT:
Please help me, its very urgent
Hello and welcome.
Everybody's question is "very urgent" to them!
You cannot access "the project folder" from runtime code as you do not know where it is, and indeed it will not even be present on a non-development machine, unless you deploy your application and include the file somewhere.
You have 4 basic choices:
- Deploy your project (e.g.
windeployqt
) to include the file somewhere, and use that. - Place the file in the same directory as your executable (or somewhere known relative to it). You can access that via e.g.
qApp-> applicationDirPath()
. - Place it in one of the paths accessible via one of the known directory paths in QStandardPaths.
- Use Qt's resource system to embed the file into the executable and
QFile
to access it there.
- Deploy your project (e.g.