swiety
19th January 2008, 22:52
I have problem with QProcess. My code:
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();
}
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?
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();
}
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?