I have problem with QProcess. My code:
{
...
private:
};
..
Mencoder::Mencoder( ...
/* some parameters */,
QObject *parent
) : QObject( parent
) {
connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( update() ) );
connect( proc, SIGNAL( finished(..) ), this, SLOT( on_finished(..) ) );
...
proc->start( "mencoder", arg );
}
void Mencoder::update()
{
......
emit newInfo( .... /*some new data for main apps*/ );
}
void Mencoder::on_finished(..)
{
..
proc->close();
deleteLater();
}
class Mencoder : public QObject
{
...
private:
QProcess *proc;
};
..
Mencoder::Mencoder( .../* some parameters */, QObject *parent ) : QObject( parent )
{
proc = new QProcess( this );
connect( proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( update() ) );
connect( proc, SIGNAL( finished(..) ), this, SLOT( on_finished(..) ) );
QStringList arg;
...
proc->start( "mencoder", arg );
}
void Mencoder::update()
{
......
emit newInfo( .... /*some new data for main apps*/ );
}
void Mencoder::on_finished(..)
{
..
proc->close();
deleteLater();
}
To copy to clipboard, switch view to plain text mode
Everything works, but i have problem with cpu usage. From system info i have this:
%CPU COMMAND
32 mencoder
40 myApps
23 xorg
Wher's the problem?
Bookmarks