I noticed something with qDebug() QTextStrean and generally stdin, stdout wanna ask, how it works actually, see this:
THIS WORKS!
method showmenu() using QTextStream
showMenu(){
QTextStream m_out(stdout);
QTextStream m_in(stdin);
m_out() << "Hey";
}
THIS DOESN'T WORK!
.h
//declaration
public:
QTextStream m_out;
QTextStream m_in;
.cpp
//method showMenu()
showMenu(){
m_out(stdout);
m_in(stdin);
m_out() << "Hey";
}
I noticed, it has problem with overloading, because also qDebug() uses stdout... am I correct?
It throws this error:
1>D:..\App_console.cpp(20,15): error : no match for call to '(QTextStream) (_IO_FILE*&)'
I have included cstdio
What could it be?
Pre C++11, You will need to do that in your Constructor Initialization List.
In the Constructor Definition of your class, say MyStreamer
, you can initialize it like this:
class MyStreamer{
....
public:
QTextStream m_out;
QTextStream m_in;
};
In your .cpp file:
MyStreamer::MyStreamer(...) : m_out(stdout), m_in(stdin) {
....
}
In C++11 and beyond, you could simply use uniform initialization:
class MyStreamer{
....
public:
QTextStream m_out{stdout};
QTextStream m_in{stdin};
};