Results 1 to 5 of 5

Thread: read stdout with QProcess under Windows

  1. #1
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default read stdout with QProcess under Windows

    Hi,
    In QIde I use ctags to populate a combo with methods of a file. I use an option of ctags "-f-" who write the result of the parsing to stdout. Then I read stdout to parse the result. The code work fine under Linux. Under Windows nothing is read and lu.isEmpty() return true. ctags is a solid tool and I requests what does not work under Windows.
    Qt Code:
    1. QProcess *testCtags = new QProcess();
    2. testCtags->start("ctags", QStringList()<<"-f-" << "--fields=+S+K+n" << filename());
    3. testCtags->waitForFinished(5000);
    4. QString lu = testCtags->readAll();
    5. if( !lu.isEmpty() )
    6. {
    7. foreach(QString s, lu.split("\n") )
    8. {
    9. ...
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 
    Note : If I use connect for readyReadStandardError or readyReadStandardOutput signals the slot is never called.
    Thanks
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  2. #2
    Join Date
    Feb 2006
    Posts
    26
    Thanked 2 Times in 1 Post
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: read stdout with QProcess under Windows

    Hi Jean Luc,

    maybe you should test the return value of waitForFinished() and just before test the return value of waitForStarted(). If one of them returns false it may be useful for better understanding the issue.

  3. #3
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: read stdout with QProcess under Windows

    I think not because if I connect readyReadStandardError or readyReadStandardOutput to a slot, this slot it's never called. If I use connect I don't delete the process by delete. Thus not problem of waiting. But never works!
    Qt Code:
    1. testCtags = new QProcess();
    2. connect(testCtags, SIGNAL(readyReadStandardError()), this, SLOT(slotLoadCtags()) );
    3. connect(testCtags, SIGNAL(readyReadStandardOutput()), this, SLOT(slotLoadCtags()) );
    4. testCtags->start("ctags", QStringList()<<"-f-" << "--fields=+S+K+n" << filename());
    5. ...
    6. //
    7. void Editor::slotLoadCtags()
    8. {
    9. QString lu = testCtags->readAllStandardOutput();
    10. ...
    11. testCtags->deleteLater();
    12. ...
    To copy to clipboard, switch view to plain text mode 
    Last edited by jlbrd; 1st September 2006 at 15:13.
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  4. #4
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: read stdout with QProcess under Windows

    Well, I created this program who wrote to stdout on Windows:
    Qt Code:
    1. #include <stdio.h>
    2. int main(int argc, char *argv[])
    3. {
    4. fprintf(stdout, "Test line\n");
    5. fflush( stdout );
    6. }
    To copy to clipboard, switch view to plain text mode 
    then I replaced ctags by stdout.exe in QProcess::start and... It's work. Thus it's ctags who don't works and not QProcess.
    End of my requests for QProcess. Now it is necessary to make work ctags!
    thanks
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

  5. #5
    Join Date
    Jan 2006
    Posts
    156
    Thanked 12 Times in 12 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: read stdout with QProcess under Windows

    In fact and after have finding, ctags works well with "-f-" to write to stdout. It's not my day, it's all!
    QDevelop, an complete Integrated Development Environment for Qt 4: http://qdevelop.org

Similar Threads

  1. need help for QProcess under windows
    By patcito in forum Qt Programming
    Replies: 4
    Last Post: 26th May 2006, 19:54
  2. QProcess problem in accessing stdout
    By aruna in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2006, 17:56
  3. QProcess +standard error + windows
    By antonio.r.tome in forum Qt Programming
    Replies: 0
    Last Post: 18th April 2006, 14:58
  4. Cannot get stdout from QProcess
    By johnny_sparx in forum Qt Programming
    Replies: 11
    Last Post: 3rd March 2006, 11:46
  5. Qprocess never end in MS windows
    By antonio.r.tome in forum Qt Programming
    Replies: 12
    Last Post: 23rd February 2006, 12:35

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.