PDA

View Full Version : QProcess readyStandardOutput()



bunjee
27th August 2009, 11:04
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.

caduel
27th August 2009, 11:14
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

bunjee
27th August 2009, 16:49
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 :


void qkShell::onReadyReadStandardOutput()
{
QString output = readAllStandardOutput();

emit outputUpdated(output, false);
}

You get the output when the complete ls is processed.

bunjee
28th August 2009, 01:15
Solved :

This heavy javascript insert procedure was the culprit :


QWebView::page()->mainFrame()->evaluateJavaScript(
QString("var newDiv = document.createElement('DIV');"
"newDiv.id = '%1';"
"newDiv.innerHTML = '%2';"
"document.getElementById('%3').appendChild(newDiv);").
arg(QString::number((int) chunk)).
arg(chunk->html()).
arg(QString::number((int) parentChunk)));

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

wysota
28th August 2009, 01:37
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.

bunjee
28th August 2009, 13:15
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 (http://qt.nokia.com/)".

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.

faldzip
29th August 2009, 06:53
for fast output you can even use QPlainTextEdit which is faster.

wysota
30th August 2009, 22:55
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...

bunjee
30th August 2009, 23:17
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 :).

wysota
30th August 2009, 23:23
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?

faldzip
31st August 2009, 10:41
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