No result by using "cout", but by "qDebug()"
I typed two examples for "Hello World" program, one using "cout" but doesn't print anything, and the other by using "qDebug()" and printed the words, why "cout doesn't work?
Code:
#include <QCoreApplication>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "Hello World!";
return a.exec();
}
Code:
#include <QCoreApplication>
#include <iostream>
#include <QDebug>
using namespace std;
int main(int argc, char *argv[])
{
//cout << "Hello World!";
qDebug() << "Hello World!";
return a.exec();
}
Re: No result by using "cout", but by "qDebug()"
Code:
int main(int argc, char *argv[])
{
std::cout << "Hello World!\n";
std::cout << "Hello World!" << std::endl;
qDebug() << "Hello World!";
return a.exec();
}
Re: No result by using "cout", but by "qDebug()"
I modified code like you explained, it still doesn't work:
Code:
#include <QCoreApplication>
#include <iostream>
#include <QDebug>
using namespace std;
int main(int argc, char *argv[])
{
std::cout << "Hello World!";
//qDebug() << "Hello World!";
return a.exec();
}
Re: No result by using "cout", but by "qDebug()"
You need the newline "\n" or "<< std::endl;"
Re: No result by using "cout", but by "qDebug()"
Quote:
I modified code like you explained, it still doesn't work
Look at this example from the Qt Wiki. You will have a much easier time if you work through the examples and tutorials instead of just writing code without a better understanding of Qt.