PDA

View Full Version : No output to console



Morea
26th February 2006, 23:23
I'm having problem getting output of this simple program in the console in w2k. In Linux, no problem, I get the expected lines. Can anyone find a problem with this? Why isn't there any output?

jacek
26th February 2006, 23:50
Add "CONFIG += console" to your .pro file.

Morea
27th February 2006, 00:09
No need to create a QApplication or QCoreApplication?

wysota
27th February 2006, 00:10
No. The console is independent of Qt.

Morea
27th February 2006, 00:13
Thank you all! Your patience with all my problems is incredible.:)

zhanxw
1st November 2007, 03:21
I have a similar program(see below), and I do add "config += console" for qmake. but I can only get the first output but not the second output. Does anyone can help me?

Mingw 3.4.5 + Windows Vista Home



#include <QProcess>
#include <QString>
#include <QByteArray>
#include <QTextStream>
#include <QDebug>

int main(int argc, char** argv){
QTextStream out(stdout);
out<<"[result]"<<endl<<flush;
qDebug()<<"debug output"<<endl;

QProcess* p;
p=new QProcess();
p->start("dir");
if (!p->waitForFinished())
return -1;
QByteArray b;
b=p->readAll();
out<<QString(b)<<endl;
qDebug()<<QString(b);
out<<"[end]"<<endl;
qDebug()<<"debug end";
return 0;
}

jacek
1st November 2007, 23:51
I have a similar program(see below), and I do add "config += console" for qmake. but I can only get the first output but not the second output.
Probably QProcess::waitForFinished() fails and the execution flow doesn't reach the second part of main(). Create QCoreApplication (or QApplication) instance at the beginning of main().