Results 1 to 5 of 5

Thread: Problem executing process

  1. #1
    Join Date
    Oct 2007
    Location
    Quebec, Canada
    Posts
    40
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Problem executing process

    I'm trying to execute a third party process using QProcess and it's almost working but fails to write the output file.

    I connected my main process to signal error, readyReadStandardOutput and readyReadStandardError and I've received all of them and it helped me debug my command line but my process should output a file and the file isn't showing.

    I searched a bit on here and had the idea to start the process detached and then it works but it pops a terminal which I don't want to see.

    Considering that the only change I made was to start it detached as opposed to a normal start, what could be the problem ? I'd guess that the processes don't have the same right but I'm not sure.

    In anyway, I'm sick of battling with this problem, help

  2. #2
    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: Problem executing process

    Can we see the code used to spawn the process? Did you check what is the current working directory when you spawn the process?

  3. #3
    Join Date
    Oct 2007
    Location
    Quebec, Canada
    Posts
    40
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem executing process

    Here's the code:
    Qt Code:
    1. QString dotExec("dot");
    2.  
    3. // Then set arguments
    4. args << QString("-T%1").arg(extension);
    5. args << QString("-o%1").arg(filename);
    6. args << QString("%1").arg(newFilename);
    7.  
    8. // Finally call the process
    9. mProcess = new QProcess;
    10. connect( mProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(OnProcessError(QProcess::ProcessError)) );
    11. connect( mProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(OnStandardOutput()) );
    12. connect( mProcess, SIGNAL(readyReadStandardError()), this, SLOT(OnErrorOutput()) );
    13. mProcess->startDetached( dotExec, args );
    14.  
    15. bool processReturn = mProcess->waitForFinished();
    16.  
    17. delete mProcess;
    18. mProcess = NULL;
    19.  
    20. return processReturn;
    To copy to clipboard, switch view to plain text mode 

    Of course waitForFinished returns false when use with startDetached() but works okay when calling start(). Right now, I'm using full path so I don't think working directory has an impact because the input file can be opened no matter what starting technique I use. It's just the output file that doesn't get written.

  4. #4
    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: Problem executing process

    Could you add the following statement somewhere after filling args and show us its output?

    Qt Code:
    1. qDebug() << args;
    To copy to clipboard, switch view to plain text mode 

    You'll need to #include <QtDebug> for that to work of course.

    Also make sure the process indeed gets started...

  5. #5
    Join Date
    Oct 2007
    Location
    Quebec, Canada
    Posts
    40
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem executing process

    Here's the output:

    ("-Tpng", "-oc:\temp\graph.png", "c:\temp\graph.dot")

    as I said, if I start it detached it works perfect except for the console popping up. So I don't think my args could be wrong.

    Also, when I start it normally(using start()), I receive the signal finished with ExitStatus = NormalExit. So I figured the process gets started.

Similar Threads

  1. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 12:54
  2. Replies: 16
    Last Post: 7th March 2006, 15:57

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.