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 change the read only files and subdirectories to writable in QT
Forum Updated to NodeBB v4.3 + New Features

how to change the read only files and subdirectories to writable in QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 3.5k Views 1 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.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by Qt Enthusiast
    #1

    I have a directory which has a sub directory

    ls Dir
    A -- directory
    B -- directory
    C -- directory
    file -

    I have to make all the sub directories and file as writable in the directory

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Is it really so hard to take a quick look at the documentation esp. since you were already hinted to the needed functions in the former thread?
      http://doc.qt.io/qt-5/qfile.html#setPermissions

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      Q 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        Is it really so hard to take a quick look at the documentation esp. since you were already hinted to the needed functions in the former thread?
        http://doc.qt.io/qt-5/qfile.html#setPermissions

        Q Offline
        Q Offline
        Qt Enthusiast
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        I have modified the question
        Please let me know the answer

        Christian EhrlicherC JonBJ 2 Replies Last reply
        0
        • Q Qt Enthusiast

          @Christian-Ehrlicher

          I have modified the question
          Please let me know the answer

          Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I don't see what I should add to my answer... permissions for a directory can be modified with QFile::setPermissions() too.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          2
          • Q Qt Enthusiast

            @Christian-Ehrlicher

            I have modified the question
            Please let me know the answer

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @Qt-Enthusiast
            You will use http://doc.qt.io/qt-5/qdir.html#entryList-1 to get a list of the files & sub-directories in the top-level directory.

            You will create QFiles on each of the returned paths, and use http://doc.qt.io/qt-5/qfile.html#setPermissions to set each file/directory's permissions.

            You will need to decide whether your intention is to recurse down each sub-directory and repeat the procedure on each of their children, or whether you only wish to set the top-level permissions in the hierarchy.

            You do not say which OS you are on, which is relevant to this question. If it's Linux this is OK. If it's Windows, AFAIK you cannot set directories read-only, or it has no effect. If you want to do this for Windows you will need to address ACLs, which is outside of Qt's scope.

            1 Reply Last reply
            2
            • Q Offline
              Q Offline
              Qt Enthusiast
              wrote on last edited by
              #6

              I will using linux and windows both versions

              JonBJ 1 Reply Last reply
              0
              • Q Qt Enthusiast

                I will using linux and windows both versions

                JonBJ Online
                JonBJ Online
                JonB
                wrote on last edited by
                #7

                @Qt-Enthusiast
                Then for Windows, what is it you expect to achieve on directories?

                OIC, you want to make them writeable, not read-only. Then that's maybe fine, I don't think you will find under Windows that your directories start read-only anyway? But if your intention is to make it so under Windows the user can now write into sub-directories where they cannot at present, then no amount of setPermissions() will achieve that, so you need to clarify what the starting situation is exactly?

                1 Reply Last reply
                0

                • Login

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