Results 1 to 4 of 4

Thread: QProcess...what's wrong

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Posts
    172
    Thanks
    30
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry QProcess...what's wrong

    I just can't get the output of "GNU locate" onto the Textedit Widget. Infact, the QByteArray is being detected empty!!

    if i start the process in startDetached(...) I can see the output on my terminal! but using only start(...) I can't seem to get it working!!

    Help pls...

    Qt Code:
    1. #include <QApplication>
    2. #include <QString>
    3. #include <QWidget>
    4. #include <QLabel>
    5. #include <QProcess>
    6. #include <QTextEdit>
    7. #include <QTextStream>
    8. #include <QByteArray>
    9.  
    10. int main(int argc,char *argv[])
    11. {
    12. QApplication app(argc,argv);
    13.  
    14. QWidget *w=new QWidget(0);
    15.  
    16. w->setGeometry(0,0,300,300);
    17.  
    18. QTextEdit *output=new QTextEdit(w);
    19.  
    20. QProcess locate;
    21. locate.setReadChannel(QProcess::StandardOutput);
    22. locate.start("locate *.mymenu");
    23.  
    24. QByteArray results=locate.readAllStandardOutput(); //readAll() too didn't work
    25.  
    26. if(results.isEmpty())
    27. {
    28. w->setWindowTitle("Sorry...doesn't work!");
    29. }
    30.  
    31. QTextStream data(&results);
    32.  
    33. output->setPlainText(data.readAll());
    34.  
    35. w->show();
    36.  
    37. return app.exec();
    38. }
    To copy to clipboard, switch view to plain text mode 



    Thanks
    Last edited by nupul; 4th May 2006 at 07:48.

Similar Threads

  1. Detect First QProcess finished in a group and kill other
    By Davidaino in forum Qt Programming
    Replies: 3
    Last Post: 11th July 2008, 12:53
  2. Replies: 2
    Last Post: 2nd June 2008, 08:45
  3. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  4. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  5. Replies: 4
    Last Post: 27th July 2006, 11:13

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.