QFile data("text.txt"); //打开指定的文件 if(data.open(QFile::WriteOnly)) //只读方式 if(data.open(QIODevice::WriteOnly))//只读方式