Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Set Environment Variable for QApplication

    General and Desktop
    2
    9
    10963
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      euchkatzl last edited by

      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 ?

      raven-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @euchkatzl last edited by raven-worx

        @euchkatzl
        yes in a platform dependent way in your operating system.
        Also check qputenv()

        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. ;)

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply Reply Quote 0
        • E
          euchkatzl last edited by

          so i have to set the variable over the terminal ?

          is there no way to set it automatically when a user starts the application ?

          raven-worx 1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators @euchkatzl last edited by

            @euchkatzl
            it seems i updated my post from before whilst you were writing yours

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply Reply Quote 0
            • E
              euchkatzl last edited by

              didn't work with qputenv().

              I've already tried this.

              raven-worx 1 Reply Last reply Reply Quote 0
              • raven-worx
                raven-worx Moderators @euchkatzl last edited by raven-worx

                @euchkatzl
                do you call it at the very beginning of your main-function?
                Even before you create your QApplication instance?

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                1 Reply Last reply Reply Quote 0
                • E
                  euchkatzl last edited by

                  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.

                  raven-worx 1 Reply Last reply Reply Quote 0
                  • raven-worx
                    raven-worx Moderators @euchkatzl last edited by raven-worx

                    @euchkatzl
                    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.

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply Reply Quote 0
                    • E
                      euchkatzl last edited by

                      Yes that worked ! Thank you very much.

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post