Reputation: 2898
With this code
#include "mainwindow.h"
#include <QApplication>
#include <iostream>
#include <QDir>
#include <QTextStream>
int main(int argc, char *argv[]){
QApplication a(argc, argv);
QTextStream out(stdout);
out << QDir::currentPath();
std::cout << "Why is that?";
MainWindow mainWindow;
mainWindow.show();
return a.exec();
}
Both messages printed only after closing Main Window of my app, why is this? I tried to debug, debugger thinks that he done with this line, but I see no messages.
Upvotes: 0
Views: 234
Reputation: 1299
extern std::ostream cout;
is buffered, so it may choose when to flush its buffer to stdout
. In your case, it is doing it when your program is terminating.
You can tell std::ostream
to flush using std::flush, as such:
std::cout << "Why is that?" << std::flush;
Upvotes: 2