How to specify the path to my main.qml file? (Python)
-
My application consists of one python file, one qml file and one application icon. I am deploying it to KDE only, so I have no dependencies to be concerned with.
How do I properly specify a path to both the QML file and the icon in my main.py file and avoid hard-coding this path?
-
Do it the Python way:
script_path = os.path.dirname(os.path.realpath(__file__))
-
Hi,
How are you deploying your application ?
-
@SGaist said in How to specify the path to my main.qml file? (Python):
Hi,
How are you deploying your application ?
I am open to suggestions. I was planning to use something like the "generic solution" mentioned here: https://doc.qt.io/qt-5/linux-deployment.html (which is to just use a shell script).
One problem I face is how (in my main.py file) can I obtain the location of that file? QCoreApplication.applicationDirPath() does not do that on Linux. If I can get the location of my main.py file (while main is executing), I can then load my QML file and application icon.
-
Do it the Python way:
script_path = os.path.dirname(os.path.realpath(__file__))
-
@SGaist You are a true champion of this forum :-)