相关疑难解决方法(0)

使用Qt时如何打印到控制台

我正在使用Qt4和C++在计算机图形学中制作一些程序.我需要能够在运行时在我的控制台中打印一些变量,而不是调试,但cout即使添加库也似乎不起作用.有没有办法做到这一点?

c++ qt cout

149
推荐指数
8
解决办法
25万
查看次数

Windows 8上的FreeConsole行为

在Windows 8上,我们遇到了FreeConsole的问题.它似乎关闭了stdio句柄,而没有关闭文件流.

这可能是Windows 8的问题,或者可能是我根本不理解Windows控制台/ GUI应用程序子系统执行操作的方式(完全荒谬).

这是怎么回事?

下面的最小例子.使用静态链接的CRT对编译器进行测试:VS2005,VS2013,VS2017.

#include <windows.h>
#include <io.h>
#include <stdio.h>

static void testHandle(FILE* file) {
  HANDLE h = (HANDLE)_get_osfhandle(fileno(file));
  DWORD flags;
  if (!GetHandleInformation(h, &flags)) {
    MessageBoxA(0, "Bogus handle!!", "TITLE", MB_OK);
  }
}

int main(int argc, char** argv)
{
  freopen("NUL", "wb", stdout); // Demonstrate the issue with NUL
  // Leave stderr as it is, to demonstrate the issue with handles
  // to the console device.

  FreeConsole();

  testHandle(stdout);
  testHandle(stderr);
}
Run Code Online (Sandbox Code Playgroud)

visual-studio-2005 msvcrt windows-8

6
推荐指数
2
解决办法
2027
查看次数

Qt qDebug()在Windows shell中不起作用

我在屏幕上使用qDebug()Qt框架printf.当我从Qt Creator运行应用程序时它工作得很好,但是当我尝试从Windows执行它时cmd它什么也没显示.为什么会这样?

printf qt console-application qdebug

5
推荐指数
1
解决办法
4015
查看次数