简体   繁体   中英

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. I'm using Qt 5.0.1.

Not even my program runs; the only thing that runs is 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.

But my question is why my program doesn't show and what is qcreator_process_stub.exe ?

Edit: Standard output doesn't even show.

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.

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.

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). 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. Every time I create a project, I have to build it with that kit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM