Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

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

    General and Desktop
    2
    5
    784
    Loading More Posts
    • 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
      ARASHz4 last edited by

      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 Reply Quote 0
      • VRonin
        VRonin last edited by

        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 Reply Quote 2
        • A
          ARASHz4 @VRonin last edited by

          @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 Reply Quote 0
          • VRonin
            VRonin last edited by

            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 Reply Quote 0
            • A
              ARASHz4 @VRonin last edited by

              @VRonin thank you but can you show me a example

              1 Reply Last reply Reply Quote 0
              • First post
                Last post