Qt standard output. cout does no print

I saw this question already on this forum but i do not know why the proposed answer does not work in my case. So I try to ask for other slution.

I'm a complete newby in c++ Qt programming. I just got my Qt crator running under linux.

i do not understand why my:

cout << "This does not appear";

does not print in console while qdebug does

qDebug() << "This appears";

this is what is contained in my .pro file:

QT       += core gui

TARGET = aaa
TEMPLATE = app


SOURCES += main.cpp\
        mainwindow.cpp \
    IeplcModule.cpp

HEADERS  += mainwindow.h \
    IeplcModule.h

FORMS    += mainwindow.ui

#enable console
CONFIG += console

Any idea?

Cheers,

Stefano

Answers


Try with cout << "asdf" << endl;

Possibly Qt sets up iostream in order to flush only at new line.


Is it possible that STDOUT is redirecting? qDebug prints to STDERR by default.


Did you #include <iostream>? I did not see any includes in the code. I assume that qdebug and cout are very similar.


When debugging with CDB (Windows debugger) and running application not in the dedicated terminal window, but within QtCreator output panel, there is an issue with std::cout/std::cerr. qDebug works because it has a trick for this case. So, the only solution in this case is enable the "run in terminal" option. For more infor please follow the link above to the Qt bug tracker.


Need Your Help

failed to find target with hash string 'android-22'

android gradle target

I have updated android studio with latest version and then after googling I also updated Android SDK with API 18 but still it gives the same error.

Is there an SQLite equivalent to MySQL's DESCRIBE [table]?

mysql sqlite

I'm just getting started learning SQLite. It would be nice to be able to see the details for a table, like MySQL's DESCRIBE [table]. PRAGMA table_info [table] isn't good enough, as it only has basic