创建一个简单的应用程序qt5.12,5.13编译它uwp mcvc 64位2017
正在尝试创建文件:
bool ret;
FILE *fp = fopen ("Name","w+"); // this command return NULL
QFile file("Name");
Ret = file. open(QIODevice::ReadWrite);还提交了:
winrtrunner.app: QIODevice::write (QFile, "Name"): device not open发布于 2019-07-07 13:38:05
如果fopen ("Name","w+")返回NULL,则无法打开该文件。因此,当您打开并尝试使用Qt内容向其写入时,几乎肯定会出现错误。
你需要找出为什么你打不开它。首先,您应该在失败的fopen之后立即检查errno,或者使用perror获得更具可读性的输出:
FILE *fp = fopen("Name", "w+");
if (fp == NULL) perror("Could not open file: ");此外,还可以使用(继承的) QIODevice::errorString()检查QFile.open()失败的原因
ret = file. open(QIODevice::ReadWrite);
if (! ret) {
const auto problem = file.errorString();
// Now log problem somehow.
}https://stackoverflow.com/questions/56919601
复制相似问题