Results 1 to 3 of 3

Thread: Passing QFile objecrt as parameter

  1. #1
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Passing QFile objecrt as parameter

    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);
    ..
    ..

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Passing QFile objecrt as parameter

    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

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Passing QFile objecrt as parameter

    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.
    J-P Nurmi

  4. The following user says thank you to jpn for this useful post:

    marcel (28th August 2007)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.