[Qt-interest] QFile and fread from resource
Constantin Makshin
cmakshin at gmail.com
Thu Nov 5 18:19:25 CET 2009
fread() is a [relatively] low-level system function and doesn't know about
Qt resource system and so can't work with it.
On Thu, 05 Nov 2009 15:04:12 +0300, Oliver Demetz
<forenbeitraege at oliverdemetz.de> wrote:
> Hi!
> Up to now I am writing and reading a data file from the filesystem via
>
> //write
> int xea[10];
> FILE * f = fopen("file.dat","wb");
> fwrite(xea, sizeof(int), 10, f);
> unsigned char byte;
> byte = (unsigned char)( 15 ) );
> fwrite(&byte, sizeof(unsigned char), 1, f);
>
> //read
> int xea[10];
> FILE * f = fopen("file.dat","rb");
> fread(xea, sizeof(int), 10, resfile)
> unsigned char byte;
> byte = getc(f);
>
> This works. If possible, I don't want to change this.
>
> I just want to move the data file into the resource file system of my
> executable (of course just for reading).
>
> does
> > fopen(":/file.dat", rb) work?
>
> I looked into QFile and QDataStream, but there is no
> fread(void* data, size_t element_size, int num, FILE * f)
> function which allows me to read an array of int's as I am doing (which
> is really comfortable).
>
>
> Thanks in advance
> Olli
--
Constantin Makshin
More information about the Qt-interest-old
mailing list