Results 1 to 5 of 5

Thread: how to update a local file at runtime

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question how to update a local file at runtime

    In my project, there is a local data file to process. I used the resources to read it. But sometime this file will be updated online. I tried to write into the source file but failed.
    Is there a way to solve this problem? thanks.

  2. #2
    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: how to update a local file at runtime

    If I understand you correctly, you want to modify a file that is embedded in the executable by way of Qt resources. You cannot do that.

    The way to solve this problem is to have the file outside of the resource system and in a writeable location on the file system (i.e. NOT the C:\Program Files\MyProg folder).

  3. #3
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: how to update a local file at runtime

    Quote Originally Posted by ChrisW67 View Post
    If I understand you correctly, you want to modify a file that is embedded in the executable by way of Qt resources. You cannot do that.

    The way to solve this problem is to have the file outside of the resource system and in a writeable location on the file system (i.e. NOT the C:\Program Files\MyProg folder).
    hi ChrisW67,
    Thanks for your reply. I have a little puzzles still.
    A Qt program have 2 folders: source folder and runtime folder. I created the data file in source folder and loaded the data file into resources. But If I used the outside path, I couldn't ensure where the data file is.
    Could you please tell me how to set the file path. thank you

  4. #4
    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: how to update a local file at runtime

    The usual approach is to have your installer put the file in an allowable location for the target platform. Suitable locations can be identified using QDesktopServices::storageLocation().

    During development (only!) you could use QCoreApplication::applicationDirPath() and put the file with the executable. DO NOT do this for a production system if you expect it to work.

  5. #5
    Join Date
    Mar 2011
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Cool Re: how to update a local file at runtime

    I see. thanks very much again!

Similar Threads

  1. local file path
    By sky in forum Newbie
    Replies: 3
    Last Post: 20th January 2011, 08:59
  2. Replies: 1
    Last Post: 22nd December 2010, 17:56
  3. Local Status Bar Does Not Update
    By shawno in forum Qt Programming
    Replies: 0
    Last Post: 16th July 2010, 01:34
  4. Replies: 4
    Last Post: 22nd June 2010, 10:59
  5. Password on local file/folder
    By icebox25 in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2007, 16:33

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
  •  
Qt is a trademark of The Qt Company.