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. File Browser with context menu to unzip files
QtWS25 Last Chance

File Browser with context menu to unzip files

Scheduled Pinned Locked Moved Unsolved General and Desktop
qfiledialogqtreeviewqfilesystemmode
7 Posts 3 Posters 1.6k 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.
  • M Offline
    M Offline
    mahesh_j
    wrote on 17 Dec 2019, 12:31 last edited by mahesh_j
    #1

    My QT tool downloads zip files. I am using a QListView with QFileSystemModel to display those zip files. Now I want the user to be able to unzip those files. So, on right click on the zip file, the user should get the same context menu actions that he gets when he right clicks on the Windows File explorer.

    I think I can get this with a QFileDialog, but QFileDialog expects the user to select files, but I just want to facilitate the user to unzip the files.

    J 1 Reply Last reply 17 Dec 2019, 12:33
    0
    • M mahesh_j
      17 Dec 2019, 12:31

      My QT tool downloads zip files. I am using a QListView with QFileSystemModel to display those zip files. Now I want the user to be able to unzip those files. So, on right click on the zip file, the user should get the same context menu actions that he gets when he right clicks on the Windows File explorer.

      I think I can get this with a QFileDialog, but QFileDialog expects the user to select files, but I just want to facilitate the user to unzip the files.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 17 Dec 2019, 12:33 last edited by
      #2

      @mahesh_j said in File Browser with context menu to unzip files:

      I think I can get this with a QFileDialog, but QFileDialog

      I would say https://doc.qt.io/qt-5/qmenu.html

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mahesh_j
        wrote on 17 Dec 2019, 12:53 last edited by
        #3

        @jsulm said in File Browser with context menu to unzip files:

        I would say https://doc.qt.io/qt-5/qmenu.html

        But I don't know what actions to add to the QMenu. So I am trying to get the Context menu displayed by the File explorer as shown in the image below. Is that possible? Or can I identify the default program for unzipping the files (7zip in my case) and invoke 7zip.exe from the QMenu?

        32d43c77-bb4b-4c5b-a3c7-d48dbd3db86b-image.png

        J J 2 Replies Last reply 17 Dec 2019, 13:06
        0
        • M mahesh_j
          17 Dec 2019, 12:53

          @jsulm said in File Browser with context menu to unzip files:

          I would say https://doc.qt.io/qt-5/qmenu.html

          But I don't know what actions to add to the QMenu. So I am trying to get the Context menu displayed by the File explorer as shown in the image below. Is that possible? Or can I identify the default program for unzipping the files (7zip in my case) and invoke 7zip.exe from the QMenu?

          32d43c77-bb4b-4c5b-a3c7-d48dbd3db86b-image.png

          J Offline
          J Offline
          JonB
          wrote on 17 Dec 2019, 13:06 last edited by
          #4

          @mahesh_j
          I am just going to throw one comment in. Your end users may not have 7zip.exe, there are many alternative ways to zip/unzip, it may be build into the OS/File Manager.

          You could try instead asking the OS to Open the Zip file, but that is likely to produce a window onto the contained files list, up to you if that is what you want.

          If you are only interested in unzipping, you could look at implementing that your in your Qt app. See e.g. https://forum.qt.io/topic/74306/how-to-manage-zip-file.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mahesh_j
            wrote on 17 Dec 2019, 13:17 last edited by
            #5

            I cannot use any 3rd party libraries due to licensing issues.

            How do I ask the OS to Open the zip files?

            J 1 Reply Last reply 17 Dec 2019, 13:32
            0
            • M mahesh_j
              17 Dec 2019, 13:17

              I cannot use any 3rd party libraries due to licensing issues.

              How do I ask the OS to Open the zip files?

              J Offline
              J Offline
              JonB
              wrote on 17 Dec 2019, 13:32 last edited by JonB
              #6

              @mahesh_j said in File Browser with context menu to unzip files:

              I cannot use any 3rd party libraries due to licensing issues.

              Up to you, zlib encoders/decoders are free/open source.

              How do I ask the OS to Open the zip files?

              https://doc.qt.io/qt-5/qdesktopservices.html#openUrl
              As I say, this is only going to use the default Open verb. It won't know to do an unzip to directory. For that you would need some nasty native Windows calls, outside of Qt.

              If you wish to re-attempt the "context menu" approach, you could look at
              https://forum.qt.io/topic/29219/is-it-possible-to-call-system-shell-context-menu-for-a-file-folder-from-qt-app
              https://stackoverflow.com/questions/21206917/how-to-get-a-context-menu-for-file-system-actions-in-qt
              where you will see you would need to go down a native WinAPI route.

              1 Reply Last reply
              4
              • M mahesh_j
                17 Dec 2019, 12:53

                @jsulm said in File Browser with context menu to unzip files:

                I would say https://doc.qt.io/qt-5/qmenu.html

                But I don't know what actions to add to the QMenu. So I am trying to get the Context menu displayed by the File explorer as shown in the image below. Is that possible? Or can I identify the default program for unzipping the files (7zip in my case) and invoke 7zip.exe from the QMenu?

                32d43c77-bb4b-4c5b-a3c7-d48dbd3db86b-image.png

                J Online
                J Online
                jsulm
                Lifetime Qt Champion
                wrote on 18 Dec 2019, 06:15 last edited by
                #7

                @mahesh_j said in File Browser with context menu to unzip files:

                But I don't know what actions to add to the QMenu

                The actions you need. You have to create such a pop-up menu.

                Take a look at http://quazip.sourceforge.net/

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                2

                2/7

                17 Dec 2019, 12:33

                5 unread
                • Login

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