在使用qt开发控制台程序的时候,想让qt在控制台下输出,可简单使用cout<<"hello world";
当输入qstring类时:
#include <iostream>
using namespace std;
Qstring str="hello";
cout<<str.toStdString();
也可以这样做:
QTextStream cout(stdout, QIODevice::WriteOnly);//不加这句,cout<<str;会出错
String str;
str = "Hello world!";
cout<<str;