[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: How to catch 'cout's' messages from program?
From:       "Adriaan de Groot" <adridg () sci ! kun ! nl>
Date:       2001-06-24 9:33:18
[Download RAW message or body]

On Sunday 24 June 2001 09:52, Oh Jin Suk wrote:
> I'd like to use other program's binary file. it generatates many 'cout' in
> C++ messages. I want to catch the messages and to show them on my dialog
> window. I will use 'system' command to execute binary files on my program.
> Could you tell me any idear to catch the console messages?

In KDE, we don't *use* system(), simply because there are far nicer tools top 
use instead. Use KProcess (see Harry? I'm learning), something like

	KProcess *p = new KProcess();
	p << "appname" << "argument" ;

	QObject::connect(p,SIGNAL(readStdin(QString)),
		this,SLOT(addToOutput(QString)));
	p->run(KProcess::NotifyOnExit,KProcess::All);

This will catch all stdout (ie. cout) messages from that process and hand 
them off to the addToOutput slot.

Note that the code above is pulled out of a hat by me, it may not work as 
written. I'd suggest you read the KProcess documentation (more 
$KDEDIR/include/kprocess.h is enough).

-- 
[ade] at home, probably hacking at KPilot
 
>> Visit http://master.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic