Results 1 to 3 of 3

Thread: Function call with QFile as parameter?

  1. #1
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Function call with QFile as parameter?

    What is the right way to do this? I need to pass QFile object to function which writes some data to file. I've tried to search example code but no success.

  2. #2
    Join Date
    Mar 2011
    Posts
    63
    Thanks
    11
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Function call with QFile as parameter?

    Qt Code:
    1. void function(QFile *file);
    To copy to clipboard, switch view to plain text mode 

    And pass your object pointer to that function. That will make it possible to edit it.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Function call with QFile as parameter?

    ... or for a C++ flavour, as a non-const reference to the QFile object.
    Qt Code:
    1. void writeToFile(QFile &file) { ... }
    2. ...
    3. QFile test;
    4. ...
    5. writeToFile(test);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 4
    Last Post: 2nd April 2010, 10:04
  2. Replies: 14
    Last Post: 1st December 2009, 20:45
  3. skip function parameter
    By mattia in forum General Programming
    Replies: 4
    Last Post: 22nd November 2007, 15:55
  4. Passing QFile objecrt as parameter
    By db in forum Newbie
    Replies: 2
    Last Post: 28th August 2007, 16:09
  5. const function parameter problems
    By stevey in forum General Programming
    Replies: 3
    Last Post: 18th December 2006, 22:22

Tags for this Thread

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.