Results 1 to 7 of 7

Thread: QProcess pipes problem

  1. #1
    Join Date
    Dec 2007
    Posts
    14
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QProcess pipes problem

    Hi folks,

    I'm relatively new to QT and I'm going nut with a weird problem. I'm using Qt 4.3.1. what i want to do is spawning a process and collect it's output to a child window, that's the code I'm executing:

    QProcess* proc = new QProcess(this);
    proc->setProcessChannelMode(QProcess::MergedChannels) ;
    connect(proc,SIGNAL(finished(int,QProcess::ExitSta tus)), this, SLOT(procFinished(int,QProcess::ExitStatus)));
    connect(proc,SIGNAL(readyRead()), this, SLOT(pipeData()));
    proc->start(app,QStringList() << "-v" << "3");

    the pipeData slot just read using readAllStandardOutput() and concatenate it in the view.

    the problem is that I receive only ONE signal with approx 4K of data, after that one, I don't get any activity further. The process I spawned has its own logging system , so I can verify that's effectively running and that's effectively dumping more data, but nothing comes from the pipes...

    any suggestion ?

    Thanks

  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: QProcess pipes problem

    How about using readAll() instead of readAllStandardOutput()? Maybe that's a problem after using MergedChannels...

  3. #3
    Join Date
    Dec 2007
    Posts
    14
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess pipes problem

    there's no difference....still get only 4K of data then it stops.

  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: QProcess pipes problem

    Could we see your pipeData() slot?

  5. #5
    Join Date
    Dec 2007
    Posts
    14
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess pipes problem

    Qt Code:
    1. void ServiceControl::pipeData() {
    2.  
    3. if (proc) {
    4. QByteArray data = proc->readAll(); // ReadAll as you suggested
    5. if (serviceMonitor) serviceMonitor->addBytes(data);
    6. }
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 7th December 2007 at 18:20. Reason: missing [code] tags

  6. #6
    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: QProcess pipes problem

    A potential problem is that you create the process and assign it to a local variable "proc" that is in your previous snippet of code istead of the "proc" member variable of the class and contents of if don't get executed.

  7. #7
    Join Date
    Dec 2007
    Posts
    14
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QProcess pipes problem

    I apologize, the output from my process isn't flushed, problem solved

Similar Threads

  1. QProcess problem (Main program hangs)
    By sincnarf in forum Qt Programming
    Replies: 5
    Last Post: 11th October 2007, 09:26
  2. Problem with qprocess
    By resal in forum Qt Programming
    Replies: 8
    Last Post: 29th August 2007, 22:13
  3. QThread and QProcess problem
    By codebehind in forum Qt Programming
    Replies: 13
    Last Post: 7th August 2007, 08:11
  4. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  5. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30

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.