QFile f("c:\\test.txt");
if(!f.open(QIODevice::WriteOnly | QIODevice::Text))
{
cout << "Open failed." << endl;
return -1;
}
QTextStream txtOutput(&f);
QString s1("123");
quint32 n1(123);
txtOutput << s1 << endl;
txtOutput << n1 << endl;
f.close();
写
QFile f("c:\\test.txt");
if(!f.open(QIODevice::ReadOnly | QIODevice::Text))
{
cout << "Open failed." << endl;
return -1;
}
QTextStream txtInput(&f);
QString lineStr;
while(!txtInput.atEnd())
{
lineStr = txtInput.readLine();
cout << lineStr << endl;
}
f.close();