Qt Forum

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

    Unsolved Reload environment on runtime

    General and Desktop
    2
    5
    1072
    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.
    • PabloArg
      PabloArg last edited by

      Hi,

      I would like to know if possible to reload the environment on runtime. Imagine the following situation. The application start and this add a path to the system, so How Do I reload the environment again that my application can see the new path?

      Thanks for your help

      K 1 Reply Last reply Reply Quote 0
      • K
        koahnig @PabloArg last edited by

        @PabloArg

        Apparently, yes with systemEnvironment
        You might want to chekc this out.

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • PabloArg
          PabloArg last edited by

          I saw that option but looks only apply if you are running some Qprocess later. But in my case I am running an external app using ShellExecuteEx of windows. I don't know if I can use it, I tried before without success.

          QProcess process;
          QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
          env.insert("TMPDIR", "C:\MyApp\temp"); // Add an environment variable
          env.insert("PATH", env.value("Path") + ";C:\Bin");
          process.setProcessEnvironment(env);
          process.start("myapp");

          1 Reply Last reply Reply Quote 0
          • PabloArg
            PabloArg last edited by

            I have a button that contain the following code:
            QStringList env(QProcess::systemEnvironment());
            qDebug() << env ;

            With my app still running I added a new path from System Property ->environment variable.

            So I click in the button but my new path doesn't show up, any ideas?

            K 1 Reply Last reply Reply Quote 0
            • K
              koahnig @PabloArg last edited by

              @PabloArg

              Nope. Unfortunately the only possibility I saw.

              Vote the answer(s) that helped you to solve your issue(s)

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