Results 1 to 11 of 11

Thread: QProcess readyStandardOutput()

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default QProcess readyStandardOutput()

    Hey guys,

    I'm using a QProcess to encapsulate a bash shell.

    I'm reading it's output from a slot connected to readyReadStandardOutput().

    I found this fairly slow compared to the console.

    Any way to boost it up ? A QThread, a Qtimer ?

    Thanks for your advice.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess readyStandardOutput()

    It is not slow (at least I never had problems with it).
    Make sure you flush stdin (if you write something) into the process's stdin. Otherwise you might end up waiting for answers the questions for which have not even been sent yet.

    Apart from that: what exactly is slow? Do you have a self contained example we can see (and try out)?

    HTH

  3. #3
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QProcess readyStandardOutput()

    I have a bash process.

    Let's say you type a "ls -l" on a pretty big directory.

    - On standard shell you'll get the output line by line.

    - On Qt using the following :

    Qt Code:
    1. void qkShell::onReadyReadStandardOutput()
    2. {
    3. QString output = readAllStandardOutput();
    4.  
    5. emit outputUpdated(output, false);
    6. }
    To copy to clipboard, switch view to plain text mode 

    You get the output when the complete ls is processed.
    Last edited by bunjee; 27th August 2009 at 17:42.

  4. #4
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QProcess readyStandardOutput()

    Solved :

    This heavy javascript insert procedure was the culprit :

    Qt Code:
    1. QWebView::page()->mainFrame()->evaluateJavaScript(
    2. QString("var newDiv = document.createElement('DIV');"
    3. "newDiv.id = '%1';"
    4. "newDiv.innerHTML = '%2';"
    5. "document.getElementById('%3').appendChild(newDiv);").
    6. arg(QString::number((int) chunk)).
    7. arg(chunk->html()).
    8. arg(QString::number((int) parentChunk)));
    To copy to clipboard, switch view to plain text mode 

    When working in a classic QTextEdit it's fast enough.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 readyStandardOutput()

    I'm wondering why people so desperately want to convert native applications into web pages... This is even funnier if you consider that bunch of other people try to make web applications look like desktop ones.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    bunjee (28th August 2009)

  7. #6
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QProcess readyStandardOutput()

    You've got a point Wysota.

    From my perspective the whole "web application" term is broken.

    Here is a personal quote:
    Some believe the web browser has to embed applications,
    I believe the web browser has to be embedded into applications
    If you consider a web browser as a widget, then you can begin to use it for what it's good at:
    - Displaying rich web content.

    Then you can do more, faster: "Code less, create more".

    Beside, the "web apps" have some huge advantages (which I won't discuss here). Standards applications surely need to evolve on some points.

    Benjamin Arnaud.

  8. #7
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess readyStandardOutput()

    for fast output you can even use QPlainTextEdit which is faster.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 readyStandardOutput()

    Quote Originally Posted by bunjee View Post
    If you consider a web browser as a widget, then you can begin to use it for what it's good at:
    - Displaying rich web content.
    But you don't have web content here. You're desperately trying to make it one. Using javascript to modify HTML tree which displays bash output inside a native application? Sorry, not a very straightforward thing to do...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QProcess readyStandardOutput()

    Quote Originally Posted by wysota View Post
    Sorry, not a very straightforward thing to do...
    We have a different approach.

    You have the technical path in mind.
    I have the final product in mind.

    The engineer and the visionary; we should work together .

  11. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 readyStandardOutput()

    Quote Originally Posted by bunjee View Post
    You have the technical path in mind.
    I have the final product in mind.

    The engineer and the visionary; we should work together .
    I think you are missing a point. What exactly do you need html for (that you can't obtain without it) in this exact situation?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #11
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess readyStandardOutput()

    I'm just guessing that it might be for some custom look and feel but in this case custom widgets/stylesheets would be better I think... Especially that I can't imagine any complicated gui to display console output :P
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

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. QProcess exitStatus()
    By user_mail07 in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2008, 20:51
  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. 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.