View Full Version : How to use C++ includes?

9th January 2006, 13:28

I have used Qt Designer to create a simple application, inside the form1.ui.h File I have my slot functions. In order to understand better when which part is called I wanted to print text output to stdout via cout << "we are here"; I have place the #include<iostream> inside the form1.ui.h file. Anyway the compiler complains that "cout" is not defined.

Am I trying something really stupid? Where do I have to place the include?


9th January 2006, 13:46
Try std::cout

9th January 2006, 13:50
Ok, found that I have to enter the include in "Includes (in Implementation)" of Qt Designer, now I can compile. But I don't see an output...

I expect to see some output after I click on file open, I have implemented:

void Form1::fileOpen()
cout << "my output";

Since it uses the standard signals/slots created by default I can't see where the error is.

9th January 2006, 13:51
Flush the output buffer:

#include <iostream>

void Form1::fileOpen(){
std::cout << "my output" << std::endl;

And remember that you have to run the application from a terminal.

BTW. It might be easier to use qDebug() instead of those cout statements.

9th January 2006, 14:34
That works perfectly! Thanks as well for the hint with qdebug. Will have a look into this as well.