Results 1 to 9 of 9

Thread: How to get reference to a file?

  1. #1
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default How to get reference to a file?

    Hi,

    I have a process that creates a file in the application path. I need to get a reference to this file in order to flush or close it.

    Making only;

    Qt Code:
    1. QFile myFile(nameOfTheFileIwantToRefer);
    To copy to clipboard, switch view to plain text mode 

    would be enough?
    Last edited by zgulser; 20th June 2012 at 13:34.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get reference to a file?

    Not really sure what you mean. You can't flush or close file opened by process A from within a different process B.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: How to get reference to a file?

    Hi again,

    I mean I'm opening a file from another dll. aFter a while I want to access this file ( somewhere at D: ) via QFile in order to flush it.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get reference to a file?

    Then you need to get the exact same handle from that dll. Opening a new handle (through QFile) won't help.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to get reference to a file?

    use QDataStream and setDevice() function in it.
    Hopes help you !
    Life is about making the right decisions and moving on.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get reference to a file?

    Quote Originally Posted by Ali Reza View Post
    use QDataStream and setDevice() function in it.
    Hopes help you !
    Tell me Ali Reza, why would using QDataStream help anything here?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to get reference to a file?

    by setDevice function, we can manage an IO device such as read specific bytes
    If i underestand correctly.
    :-)
    Life is about making the right decisions and moving on.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to get reference to a file?

    Quote Originally Posted by Ali Reza View Post
    such as read specific bytes
    Is that what this thread is about?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Jun 2012
    Location
    Iran , Tehran
    Posts
    93
    Thanks
    5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to get reference to a file?

    oh
    excuse me sir.
    my post did not related.
    excuse again ...
    Life is about making the right decisions and moving on.

Similar Threads

  1. undefined reference
    By digidas in forum Newbie
    Replies: 9
    Last Post: 19th May 2010, 13:04
  2. How can Stylesheet reference non resource image file
    By dpatel in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2010, 08:41
  3. Reference to ui
    By Phalanx in forum Qt Programming
    Replies: 7
    Last Post: 22nd April 2010, 15:58
  4. undefined reference
    By jayreddy in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2009, 13:45
  5. Pass by reference
    By vermarajeev in forum General Programming
    Replies: 6
    Last Post: 20th July 2007, 14:53

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.