Qt tostdString

Qt 输出文件时string要转到std型,

#include 
#include 
#include 

void io::write_to_file(QString str)
{
    ofstream my_file;
    my_file.open("test.txt");
    my_file << str.toStdString();
    my_file.close();
    return;
 
  
        }

输出到console也一样,

QString string;
// do things...
std::cout << string << std::endl;

你可能感兴趣的:(Qt)