Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Set Environment Variable for QApplication

Set Environment Variable for QApplication

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 12.8k Views
  • 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 Offline
    E Offline
    euchkatzl
    wrote on last edited by
    #1

    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-worxR 1 Reply Last reply
    0
    • E euchkatzl

      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-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @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
      0
      • E Offline
        E Offline
        euchkatzl
        wrote on last edited by
        #3

        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-worxR 1 Reply Last reply
        0
        • E euchkatzl

          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-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @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
          0
          • E Offline
            E Offline
            euchkatzl
            wrote on last edited by
            #5

            didn't work with qputenv().

            I've already tried this.

            raven-worxR 1 Reply Last reply
            0
            • E euchkatzl

              didn't work with qputenv().

              I've already tried this.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #6

              @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
              0
              • E Offline
                E Offline
                euchkatzl
                wrote on last edited by
                #7

                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-worxR 1 Reply Last reply
                0
                • E euchkatzl

                  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-worxR Offline
                  raven-worxR Offline
                  raven-worx
                  Moderators
                  wrote on last edited by raven-worx
                  #8

                  @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
                  0
                  • E Offline
                    E Offline
                    euchkatzl
                    wrote on last edited by
                    #9

                    Yes that worked ! Thank you very much.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved