Results 1 to 8 of 8

Thread: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

  1. #1
    Join Date
    May 2010
    Posts
    42

    Question how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

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

    hi guys!
    how to use the top codes in linux?I have tried many times.but end up with failure.what bother me was the third and fourth line.

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    What "failure" are you talking about?

    Note that QProcessEnvironment was added to Qt 4.6. What version of Qt are you using?

  3. #3
    Join Date
    May 2010
    Posts
    42

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    Quote Originally Posted by SixDegrees View Post
    What "failure" are you talking about?

    Note that QProcessEnvironment was added to Qt 4.6. What version of Qt are you using?
    I'm using Qt 4.6.2.my problem is that i didn't understand the use of setProcessEnvironment ( const QProcessEnvironment & env) indeed.especially the insert

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    It sets the environment variable to the value provided. It performs exactly the same function as 'setenv [name] [value]' or 'export [name]=[value]'does in the shell.

  5. #5
    Join Date
    May 2010
    Posts
    42

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    Quote Originally Posted by SixDegrees View Post
    It sets the environment variable to the value provided. It performs exactly the same function as 'setenv [name] [value]' or 'export [name]=[value]'does in the shell.

    If I want to start "drcomd" with QProcess,how to set the enviroment ?requesting super Konsole will be best. take my top codes for example in linux.

  6. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    I have no idea what 'drcomd' is, or what environment variable settings it might be expecting. If it's a console command, the documentation for it should note whatever is required to run it.

    Do you know what enviornment variables are? If not, search on that term and read up on them.

  7. #7
    Join Date
    May 2010
    Posts
    42

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    Quote Originally Posted by SixDegrees View Post
    I have no idea what 'drcomd' is, or what environment variable settings it might be expecting. If it's a console command, the documentation for it should note whatever is required to run it.

    Do you know what enviornment variables are? If not, search on that term and read up on them.
    ok! the drcomd is a console command.I just take it for example,it can be anything else console command.

  8. #8
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: how to use setProcessEnvironment ( const QProcessEnvironment & env) in Linux?

    You need to learn what environment variables are, and what they are used for. In general, you don't need to set environment variables in order for most commands to execute properly. There are, however, exceptions, and in those cases you might need to use the setProcessEnvironment() call to provide them.

    If you can execute your command at the console prompt, you probably don't need to worry about setting environment variables for it. Not understanding them, however, is likely to cause problems later.

Similar Threads

  1. Problem with the const
    By aekilic in forum Qt Programming
    Replies: 13
    Last Post: 9th April 2010, 08:10
  2. Replies: 1
    Last Post: 4th December 2009, 17:03
  3. Returning const &
    By frenk_castle in forum Newbie
    Replies: 2
    Last Post: 24th November 2009, 07:01
  4. const member and const method
    By mickey in forum General Programming
    Replies: 8
    Last Post: 9th April 2008, 09:44
  5. could somebody please explain const to me?
    By mikro in forum General Programming
    Replies: 4
    Last Post: 29th September 2006, 14:34

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.