Results 1 to 6 of 6

Thread: After setting environment, QProcess::start() no effect.

  1. #1
    Join Date
    Mar 2009
    Posts
    20
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default After setting environment, QProcess::start() no effect.

    Dear all,
    I have a new question for QProcess, my Qt's verison is Qt4.3.
    I want to run a program by QProcess, the program need to soure env before running it.
    In my program, I do like below:
    QProcess *proc = new QProcess();
    QStringList env = QObject::systemEnvironment();
    env<<"~azhang/env/tool.env" ; // run the program need soure it.
    proc->setEnvironment(env);

    QStringList args;
    args<<file1<<file2
    proc->start(proc,args );

    When I do this, the program can not be started, and the errorcode is 5 (unknow error).
    So, where is my wrong?
    Please help, thanks!

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: After setting environment, QProcess::start() no effect.

    Quote Originally Posted by aaron View Post
    env<<"~azhang/env/tool.env" ; // run the program need soure it.
    This is wrong way to add an environment.
    You should provide a key=value pair.
    So better do something like this :
    Qt Code:
    1. env << "TMPDIR=C:\\MyApp\\temp";
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2009
    Posts
    20
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: After setting environment, QProcess::start() no effect.

    Dear yogeshgokul,
    Thank you !
    I have ever set the env like : env <<"PATH = /home/azhang/env/tool.env" ,
    but the result is same. Why?

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: After setting environment, QProcess::start() no effect.

    Quote Originally Posted by aaron View Post
    Dear yogeshgokul,
    Thank you !
    I have ever set the env like : env <<"PATH = /home/azhang/env/tool.env" ,
    but the result is same. Why?
    Its hard to decide upon little information.
    What if you add that path permanently in path variable using command promt or terminal and not with qt app itself ?
    I just wanna be sure that adding
    home/azhang/env/tool.env"
    in path is making any difference anyway.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: After setting environment, QProcess::start() no effect.

    Quote Originally Posted by aaron View Post
    I have ever set the env like : env <<"PATH = /home/azhang/env/tool.env" ,
    but the result is same. Why?
    Setting PATH before running QProcess has little sense. What are you trying to obtain this way? Because the only thing I can think about is that you'll be running bash to execute a script that runs some other programs which are not in the system path - but then you could have set that path directly in the script itself.

    Besides, "/home/azhang/env/tool.env" doesn't look like a directory name, it's more likely a file, so setting it to PATH doesn't make sense.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: After setting environment, QProcess::start() no effect.

    I have ever set the env like : env <<"PATH = /home/azhang/env/tool.env" ,
    but the result is same. Why?
    The space either side of the "=" sign may cause issues.
    Qt Code:
    1. env << "TMPDIR=C:\\MyApp\\temp";
    To copy to clipboard, switch view to plain text mode 
    is good and
    Qt Code:
    1. env << "TMPDIR = C:\\MyApp\\temp";
    To copy to clipboard, switch view to plain text mode 
    is probably not.

Similar Threads

  1. setting environment for process
    By afflictedd2 in forum Qt Programming
    Replies: 0
    Last Post: 18th March 2009, 17:17
  2. Eclipse question
    By MarkoSan in forum General Discussion
    Replies: 5
    Last Post: 18th November 2008, 08:38
  3. problem with indexes
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2007, 14:55

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.