qt使用std::cout 打印信息

时间:2014-09-02 19:58:05   收藏:0   阅读:1212

场景:在Qt里,不能使用std::cout在 "输出" 下输出信息,所以使用下面的函数就可以打印cout的内容了

#include <io.h>
#include <fcntl.h>
static void OpenConsole()
{    
	AllocConsole();    
	HANDLE   handle   =   GetStdHandle(STD_OUTPUT_HANDLE);    
	int   hCrt   =   _open_osfhandle((long)handle,_O_TEXT);    
	FILE   *   hf   =   _fdopen(   hCrt,   "w"   );    
	*stdout   =   *hf;    
}


原文:http://blog.csdn.net/taoerit/article/details/39010023

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!