Qt:把内容写进字符串(使用QTextStream包装QString)

#include <iostream>
#include <QChar>
#include <QFile>
#include <QTextStream>
#include <sstream>
#include <string>

int main(int argc, char *argv[]) {
// Qt
QString str;
QTextStream(&str) << "Number: " << hex << 16 << oct << " " << 20;
std::cout << str.toStdString() << std::endl;

// C++ 
std::string sstr;
std::ostringstream ostrm;
ostrm << "Was: " << 234;
sstr = ostrm.str();
std::cout << sstr << std::endl;

return 0;
}

猜你喜欢

转载自blog.csdn.net/lengyuezuixue/article/details/80712885