问题遇到的现象和发生背景
请问,在Ubuntu我在qt下开发的一个聊天软件,但传输文件传输不过去,这是为什么呢?
问题相关代码,请勿粘贴截图
if(msgType == "receiveFile"){
QString sendUser,receiveUser,fileStr;
QByteArray fileData;
in >> sendUser >> receiveUser >> fileStr >>fileData;
if(!fileData.isEmpty()){
QString fileName = QFileDialog::getExistingDirectory();
QFile file(fileName+"/"+fileStr);
file.open(QIODevice::WriteOnly);
file.write(fileData);
file.close();
}
}
运行结果及报错内容
QIODevice::write (QFile, "/components.xml"): device not open