Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Prevent Deleting a currently Opened file Using Qt.
Forum Updated to NodeBB v4.3 + New Features

Prevent Deleting a currently Opened file Using Qt.

Scheduled Pinned Locked Moved Unsolved Brainstorm
8 Posts 4 Posters 2.9k Views 2 Watching
  • 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.
  • HashTagJFH Offline
    HashTagJFH Offline
    HashTagJF
    wrote on last edited by HashTagJF
    #1

    In Microsoft word, the user is not allowed to delete or rename a file if it is in used. I want to create a project that is similar to this. But how am I going to do that? I am new to QT. I don't know how to start. Can anyone help me with this?
    I'm looking forward for your reply.
    Thank you so much in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      AFAIK, that's the OS that forbids such operations on an opened file.

      Or are you trying to do such things within your application ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • HashTagJFH Offline
        HashTagJFH Offline
        HashTagJF
        wrote on last edited by
        #3

        Hi thank you so much for your reply.
        Yes, I am trying to create that within my application.
        I made a project that could save and edit a text file. Like a notepad. What I want is if that file is opened. I want a messagebox or something that will pop up when the user tries to delete/rename the certain file.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          How is the user supposed to delete the file ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • HashTagJFH Offline
            HashTagJFH Offline
            HashTagJF
            wrote on last edited by
            #5

            Hmmmm.. Let's say for example you have a saved file called "sample.txt" in the documents. Then you open it using the application you created in QT. Then the user will try to delete that file in the documents. I want a message to pop up... something like "action cannot be completed because the file is open in another application." something like this.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Konstantin Tokarev
              wrote on last edited by
              #6

              You need some kind of file lock, and pray that deleting application respects your lock.

              kshegunovK 1 Reply Last reply
              2
              • K Konstantin Tokarev

                You need some kind of file lock, and pray that deleting application respects your lock.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                You need some kind of file lock, and pray that deleting application respects your lock.

                Which on *nix is (almost) never the case.

                Read and abide by the Qt Code of Conduct

                1 Reply Last reply
                1
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  One alternative that comes to mind is to work on a "copy" of the file and next time you save it you can tell your user that the file is gone.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1

                  • Login

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