Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. how to when use a file can't delete the file

how to when use a file can't delete the file

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ARASHz4
    wrote on 23 Jun 2016, 16:33 last edited by
    #1

    Hi
    When i load a file to my app should can't delete or rename the file, when my app using the file.
    how to do this?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 23 Jun 2016, 16:42 last edited by
      #2

      Check QLockFile

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      A 1 Reply Last reply 23 Jun 2016, 16:53
      2
      • V VRonin
        23 Jun 2016, 16:42

        Check QLockFile

        A Offline
        A Offline
        ARASHz4
        wrote on 23 Jun 2016, 16:53 last edited by
        #3

        @VRonin how to use correctly?
        this my code :

        QLockFile lf("J:/file.txt");
        lf.lock();
        

        whit this code file deleted & app crash(exit code 1073741845) & anti virus alert me my app is virus!

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 23 Jun 2016, 16:57 last edited by
          #4

          please read the description of the class

          For the use case of protecting a resource over a long time, you should therefore call setStaleLockTime(0), and when tryLock() returns LockFailedError, inform the user that the document is locked, possibly using getLockInfo() for more details.

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          A 1 Reply Last reply 23 Jun 2016, 17:42
          0
          • V VRonin
            23 Jun 2016, 16:57

            please read the description of the class

            For the use case of protecting a resource over a long time, you should therefore call setStaleLockTime(0), and when tryLock() returns LockFailedError, inform the user that the document is locked, possibly using getLockInfo() for more details.

            A Offline
            A Offline
            ARASHz4
            wrote on 23 Jun 2016, 17:42 last edited by
            #5

            @VRonin thank you but can you show me a example

            1 Reply Last reply
            0

            3/5

            23 Jun 2016, 16:53

            • Login

            • Login or register to search.
            3 out of 5
            • First post
              3/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved