- 论坛徽章:
- 0
|
这个代码是从qui4mplayer(基于qt 3.3.5) 这中看到的,这个函数可以被用来在需要显示 *调试信息* 的时候。
发出一个信号,让该槽执行,利用它打印调试信息。
在这个例子里,调试信息来自mplayer播放的“文字输出”。
// Slot that can have any particular signal connected to it to test various things
void PlayFile::debugslot()
{
cout canReadLineStderr())
cout readLineStderr() class myclass{
private:
QString debugMsg;
void init();
...
public:
void doSomeThing();
...
signal:
needDebug();
...
public slot:
void debugslot();
...
};
void myclass::init()
{
...
connect(this,needDebug,this,debugslot);
}
myclass::doSomeThing()
{
...
debugMsg = state;
emit needDebug();
}
void debugslot( )
{
cout "debug info: "debugMsg.latinl()endl;
}
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/61322/showart_1795875.html |
|