Skip to content

Instantly share code, notes, and snippets.

@e12e
Last active August 29, 2015 14:16
Show Gist options
  • Save e12e/f79e9f0e66ee3600e0aa to your computer and use it in GitHub Desktop.
Save e12e/f79e9f0e66ee3600e0aa to your computer and use it in GitHub Desktop.
Idiomatic way of writing eol and flushing stdout with qt5?
#include <QTextStream>
int main(int, char*[])
{
// Works, but is hacky (note: empty string):
// QTextStream(stdout) << "" << endl;
// Does not compile:
// QTextStream(stdout) << endl;
// Best? way (thanks to suy on #qt@freenode):
QTextStream out(stdout);
out << endl;
return 0;
}
@e12e
Copy link
Author

e12e commented Mar 9, 2015

To test:

mkdir qt
cd qt
wget https://gist.github.com/e12e/f79e9f0e66ee3600e0aa/raw/7ab8239060134601e93a0013706df638af0b3edf/qt.cpp
qmake -project
qmake -makefile
make
./qt # outputs empty line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment