将QFile转换为FILE * [英] Convert QFile to FILE*

查看:1838
本文介绍了将QFile转换为FILE *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有另一种方法来确定QFile到文件?不同于此:

Is there another way to convet QFile to File? Different than this:

QFile myFile("goforward.raw");
int FileDescriptor = myFile.handle();
FILE* fh = fdopen(FileDescriptor, "rb");


推荐答案

我想你已经知道, code>打开,等方法。也就是说,如果文件没有打开,那么句柄方法返回一个错误。

I think you already know that you have the various open, read, etc. methods in QFile. That said, if the file is not opened, then the handle method returns an error.

QFile myFile("goforward.raw");
myFile.open(QIODevice::ReadOnly);
int fileHandle = myFile.handle();

之后,您可以重新打开它:

After that, you might reopen it with:

FILE* fh = fdopen(fileHandle, "rb");

这篇关于将QFile转换为FILE *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆