QString readCookie()
{
QString path = QCoreApplication::applicationDirPath();
path.append("/cookies/cookie.txt");
qDebug()<<path;
QString strCookie = "";
QFile file(path);
bool error = file.open(QIODevice::ReadWrite);
if(error)
{
QByteArray data = file.readAll();
strCookie.append(data);
qDebug()<<"-------------- readCookie start ---------------";
qDebug()<<strCookie.size()<<strCookie;
qDebug()<<"-------------- readCookie end ---------------";
file.close();
}
return strCookie;
}
文件读取QFile用法例子