Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Set Environment Variable for QApplication
Is there a possibility to set a QT Environment Variable not only for launching in Qt Creator ?
I have to set QT_HARFBUZZ=old permanently.
Also for Launching the App in Release Mode.
Can this be done in qt.conf file ?
But keep in mind that it might be too late to set the variable when the reading code has been already executed (e.g. when initialized statically). But simply give it a try and see if it works for your case i would say. ;)
so i have to set the variable over the terminal ?
is there no way to set it automatically when a user starts the application ?
it seems i updated my post from before whilst you were writing yours
didn't work with qputenv().
I've already tried this.
do you call it at the very beginning of your main-function?
Even before you create your QApplication instance?
yes but it has no effect for my problem.
Im using Qt 5.3.2 and on OS X text align justifiy for QGraphicsTextItem did not work when QT_HARFBUZZ=old is not set.
Nevermind i see. Exactly what i was talking before about the one caveat.
qfontengine.cpp initializes a global variable depending on the value of the QT_HARFBUZZ environment variable.
So it gets initialized as soon as the module is loaded. Which is before your main is called. Unfortunately the initialization order is undefined for global/static variables (across different translation units in the compiler).
So you wont have a guarantee that your qputenv() is called before it is read by Qt (in case you are also setting it as static/global variable).
An idea which would work is to write a simple wrapper application, which spawns your gui application using QProcess with the environment variable set.
Your decision if you wanna go this way.
Yes that worked ! Thank you very much.