PDA

View Full Version : Terminal output works but not within QT - Why ?



fredmeyter
20th January 2013, 15:51
I've started using QT4.8.3 and have a very simple question :

When I execute my compiled programm in a linux terminal window the output using the cout command works fine and the program does what it should do. But within QT when I click on Run there are no errors, a terminal window opens but there is no output. Why is there no output in QT but when executing the same program in a terminal window manually it shows the correct output ?

alizadeh91
20th January 2013, 17:17
can u post a sample code? Did you create console app?

fredmeyter
20th January 2013, 17:41
I selected QT console application for this test project and actually the problem already occurs with a basic hello world code like this :

This is my .pro file :

# Project created by QtCreator 2013-01-20T15:42:31
#
#-------------------------------------------------

QT += core

QT -= gui

TARGET = tutorial1
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app


SOURCES += main.cpp



and this is the main.cpp :

#include <QCoreApplication>
#include <iostream>
using namespace std;


int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

cout << "Hello World" << endl;

return a.exec();
}


This prints Hello World when executed from a linux terminal but no output within the terminal window opened by QT after compiling...

wysota
20th January 2013, 18:11
Qt doesn't open any console windows.