PDA

View Full Version : Passing QFile objecrt as parameter



db
28th August 2007, 14:11
How do I pass a QFile object as a paramter. I'm rehoisting some code that use to pass in the file pointer to the method. I've redone it to use QString and QFile. But when I try to compile I get an error saying that the QFile object is private...

the declaration is...

CNewProcess::ReadCommand(QFile cmdFile, in_buff_t buff[], *int items);

I call it as follows...

QFile commandFile("/tmp/commands.txt");
.
.
ReadCommands(commandFile, inputBuff, count);
..
..

marcel
28th August 2007, 14:26
Pretty hard to say. If you switched from a pointer var, have you modified all references in the the code not to use pointers?


Regards

jpn
28th August 2007, 16:09
QFile is a QObject. QObjects cannot be copied for a reason. Passing by value means copying. So you must either pass by reference or pass a pointer.