[英]C++ - QtCreator doesn't show any output
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
qDebug() << "hello";
return a.exec();
}
This basic application doesn't work when building and running in QtCreator 2.6.2. 在QtCreator 2.6.2中构建和运行时,此基本应用程序不起作用。 I'm using Qt 5.0.1. 我正在使用Qt 5.0.1。
Not even my program runs; 甚至我的程序都没有运行; the only thing that runs is qcreator_process_stub.exe
. 唯一运行的是qcreator_process_stub.exe
。 In my .pro
file, the line CONFIG += console
is there, and in my .pro.user
file, UseTerminal
is set to true. 在我的.pro
文件中,行CONFIG += console
就在那里,在我的.pro.user
文件中, UseTerminal
设置为true。
But my question is why my program doesn't show and what is qcreator_process_stub.exe
? 但我的问题是为什么我的程序没有显示,什么是qcreator_process_stub.exe
?
Edit: Standard output doesn't even show. 编辑:标准输出甚至不显示。
http://qt-project.org/doc/qt-5.0/qtcore/qdebug.html#details http://qt-project.org/doc/qt-5.0/qtcore/qdebug.html#details
qcreator_process_stub.exe
is the default terminal that Qt Console programs get executed in. qcreator_process_stub.exe
是Qt控制台程序执行的默认终端。
http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#qDebug http://qt-project.org/doc/qt-5.0/qtcore/qtglobal.html#qDebug
This function does nothing if QT_NO_DEBUG_OUTPUT was defined during compilation. 如果在编译期间定义了QT_NO_DEBUG_OUTPUT,则此函数不执行任何操作。
Try putting this at the top of your main: 试着把它放在主要的顶部:
#ifdef QT_NO_DEBUG_OUTPUT
#undef QT_NO_DEBUG_OUTPUT
#endif
I found the problem. 我发现了这个问题。
QtCreator was detecting the wrong MinGW version on my system (as I used another version for Code::Blocks). QtCreator在我的系统上检测到错误的MinGW版本(因为我使用了另一个版本的Code :: Blocks)。 What I did was: 我做的是:
Tools > Options... > Build & Run > Kits 工具>选项...>构建和运行>套件
I then cloned the Auto-detected kit, and changed the compiler to the one that shipped with QtCreator. 然后我克隆了自动检测的工具包,并将编译器更改为QtCreator附带的编译器。 Every time I create a project, I have to build it with that kit. 每次创建项目时,我都必须使用该工具包构建它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.