当前位置: 动力学知识库 > 问答 > 编程问答 >

Qt C++ No output to stdout when console application is executed directly

问题描述:

I'm new to Qt and used the example project xmlstreamlint. When I do a printf in main I see the output when I run the application from QT Creator. But when I navigate to the debug directory and run the exe from a command shell I see no output.

I searched the internet for hours and tried things like this:

//freopen ("/dev/tty", "a", stdout);

QTextStream(stdout) << "string to print" << endl;

qDebug("Hallo q1");

qStdOut() << "Hallo\n";

std::cout << "\nHello World!\n";

std::cout << "Hallo" <<endl;

fflush(stdout);

freopen crashes when run from QT Creator and it doesn't when running the exe from command shell.

My project file looks like this (it comes from the example)

CONFIG += console

CONFIG -= app_bundle

QT -= gui

QT += xml

SOURCES += main.cpp

# install

target.path = $$[QT_INSTALL_EXAMPLES]/xml/xmlstreamlint

INSTALLS += target

I need help. Absolutely no output when executed from the command shell. Even with qDebug().

Maybe the wrong exe? I found xmlstreamlint.exe in

C:\Qt\Examples\Qt-5.7\xml\build-xmlstreamlint-Desktop_Qt_5_7_0_MSVC2013_64bit-Debug\debug

and the date is updated each time I build.

That kills me...

Thanks for any ideas.

分享给朋友:
您可能感兴趣的文章:
随机阅读: