Results 1 to 9 of 9

Thread: Problem with qprocess

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Problem with qprocess

    Quote Originally Posted by resal View Post
    what that they expected to have. stderr messages in err file, and stdout menu in out file.
    OK, so at least that application isn't playing any tricks by detecting whether the input comes from a file or a terminal.

    There is no way to control the buffers through QProcess, but maybe reimplementing QProcess::setupChildProcess() will help. You might try to alter the buffer size with setbuf, but I'm not sure if it's going to work (I think I've tried it to solve a similar problem, but without a success).

    Quote Originally Posted by resal View Post
    Do you know any (not-very-complicated) (especially in Qt4) application with similar functionality?
    Unfortunately, I don't.

    Quote Originally Posted by resal View Post
    I reviewed konsole code, but got lost in (kde-related) classes....
    kconsole doesn't use pure QProcess, but a K3Process subclass. The most important difference is that KDE allows you to use a pty device to communicate with the child process.

    Here are the relevant sources:
    http://websvn.kde.org/trunk/KDE/kdeb....h?view=markup
    http://websvn.kde.org/trunk/KDE/kdeb...pp?view=markup
    http://api.kde.org/4.0-api/kdelibs-a...rocess_8h.html
    http://api.kde.org/4.0-api/kdelibs-a...classKPty.html

  2. The following user says thank you to jacek for this useful post:

    resal (28th August 2007)

  3. #2
    Join Date
    Aug 2007
    Posts
    5
    Thanks
    1

    Default Re: Problem with qprocess

    Thank you jacek.

    I have reviewed them before. As you said the trick in konsole is using kpty device.

    Quote Originally Posted by jacek View Post
    There is no way to control the buffers through QProcess, but maybe reimplementing QProcess::setupChildProcess() will help. You might try to alter the buffer size with setbuf, but I'm not sure if it's going to work (I think I've tried it to solve a similar problem, but without a success).
    I think this is the case. I 've played with setupChild Process() but I couldn't figured it out how to use it. I found these links though :
    http://labs.trolltech.com/blogs/2006...with-qprocess/
    http://www.koders.com/default.aspx?s...arch&la=*&li=*
    http://www.koders.com/cpp/fidCB4E6B7...upchildprocess

    The first one, I think, is the solution. I tried to find some example of its usage, so I search koders, which didn't help me a lot.

    Can anyone write an example code about how to use the method that first link suggest?

    Thanks in advance.

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Problem with qprocess

    Quote Originally Posted by resal View Post
    I think this is the case. I 've played with setupChild Process() but I couldn't figured it out how to use it.
    You have to create a QProcess subclass and use that new class instead.
    Qt Code:
    1. class UnbufferedProcess : public QProcess
    2. {
    3. protected:
    4. void setupChildProcess()
    5. {
    6. ::setbuf( stdout, 0 );
    7. }
    8. };
    To copy to clipboard, switch view to plain text mode 
    But as I said, I'm not sure if it's going to help.

    Quote Originally Posted by resal View Post
    The first one, I think, is the solution. I tried to find some example of its usage, so I search koders, which didn't help me a lot.
    You use it just like QProcess, but I'm not sure if it solves your problem. I think that this class is useful if the process you want to start insists on reading from the terminal. Nevertheless, try it.

Similar Threads

  1. QThread and QProcess problem
    By codebehind in forum Qt Programming
    Replies: 13
    Last Post: 7th August 2007, 09:11
  2. Quoting problem with QProcess
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2006, 12:24
  3. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 14:30
  4. QProcess problem in accessing stdout
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2006, 18:56
  5. QProcess problem with windows batch file
    By bood in forum Qt Programming
    Replies: 11
    Last Post: 6th January 2006, 09:08

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
  •  
Qt is a trademark of The Qt Company.