开发者

How can I monitor QProcess finished() in qt4 (Signal/Slot)

It looks as if their was a solution for this in qt3, but I cannot find one for qt4 (all I have used, goggling I saw solutions for qt3).

connect(r, SIGNAL(rea开发者_运维知识库dyReadStandardError()), this, SLOT(updateError()));
connect(r, SIGNAL(readyReadStandardOutput()), this, SLOT(updateText()));
connect(r, SIGNAL(finished(int exitcode)), this, SLOT(updateExit()));

I have my stdout/stderr SIGNAL/SLOT's working just fine, but I cannot seem to find a good solution for finished. I cannot do anything in a loop or proc->waitforfinished because I need constant updated to my UI. How can I do this?

My error: Object::connect: No such signal QProcess::finished(int exitcode)

Thanks

Below are the SIGNALS for QProcess....

Signals
void    error ( QProcess::ProcessError error )
void    finished ( int exitCode, QProcess::ExitStatus exitStatus )
void    readyReadStandardError ()
void    readyReadStandardOutput ()
void    started ()
void    stateChanged ( QProcess::ProcessState newState )


replace your code line

connect(r, SIGNAL(finished(int exitcode)), this, SLOT(updateExit()));

with

connect(r, SIGNAL(finished(int)), this, SLOT(updateExit()));

When connection signals and slots dont give a parameter name.


I feel like I'm missing something here, but I have a few minutes... :)

What's wrong with the finished signal in 4.x? It just adds a few parameters to what you have from what I can tell.

4.5:

void QProcess::finished( int exitCode, QProcess::ExitStatus exitStatus )

4.0:

void QProcess::finished( int exitCode )

Change your slot to have the correct arguments and just ignore them if you don't need them.

As for needing status updates, launch the new QProcess in a separate thread and let that thread do the waiting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜