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. Connect to network drive
Forum Updated to NodeBB v4.3 + New Features

Connect to network drive

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 2.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.
  • banditoB Offline
    banditoB Offline
    bandito
    wrote on last edited by
    #1

    So I am attempting to build an app that will backup my files to a network drive.

    Presently my network drive is a usb stick connected to my router. At the moment I can't figure out ho to connect to the network drive using Qt. I have fiddled with QDir and QDesktopServices but I cannot get either to list the files on the network drive. Could someone point me in the right direction? Thanks.

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

      You need to mount it with your local OS, no help from Qt here.

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

      banditoB 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        You need to mount it with your local OS, no help from Qt here.

        banditoB Offline
        banditoB Offline
        bandito
        wrote on last edited by
        #3

        @Christian-Ehrlicher said in Connect to network drive:

        You need to mount it with your local OS, no help from Qt here.

        I already have it mounted.

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

          Hi,

          What OS are you using ?
          How is your drive seen by this OS ?
          How are you trying to access it with Qt ?

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

          banditoB 1 Reply Last reply
          0
          • banditoB bandito

            @Christian-Ehrlicher said in Connect to network drive:

            You need to mount it with your local OS, no help from Qt here.

            I already have it mounted.

            Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @bandito said in Connect to network drive:

            I already have it mounted.

            Then you can simply use QFile with the path in the filesystem

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

            banditoB 1 Reply Last reply
            1
            • SGaistS SGaist

              Hi,

              What OS are you using ?
              How is your drive seen by this OS ?
              How are you trying to access it with Qt ?

              banditoB Offline
              banditoB Offline
              bandito
              wrote on last edited by
              #6

              @SGaist said in Connect to network drive:

              Hi,

              What OS are you using ?
              How is your drive seen by this OS ?
              How are you trying to access it with Qt ?

              • Linux (Ubuntu)
                -As a windows share (no username or password)
                -I tried QDir which appears to make a connection but I can't get a list of files and directories. I also tried QDesktopServices but it didn't work at all.
              1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @bandito said in Connect to network drive:

                I already have it mounted.

                Then you can simply use QFile with the path in the filesystem

                banditoB Offline
                banditoB Offline
                bandito
                wrote on last edited by
                #7

                @Christian-Ehrlicher said in Connect to network drive:

                @bandito said in Connect to network drive:

                I already have it mounted.

                Then you can simply use QFile with the path in the filesystem

                Yes but this way you cannot list the files/folders of the network drive.

                aha_1980A 1 Reply Last reply
                0
                • banditoB bandito

                  @Christian-Ehrlicher said in Connect to network drive:

                  @bandito said in Connect to network drive:

                  I already have it mounted.

                  Then you can simply use QFile with the path in the filesystem

                  Yes but this way you cannot list the files/folders of the network drive.

                  aha_1980A Offline
                  aha_1980A Offline
                  aha_1980
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @bandito said in Connect to network drive:

                  Yes but this way you cannot list the files/folders of the network drive.

                  Seems you are looking for https://doc.qt.io/qt-5/qdiriterator.html

                  Regards

                  Qt has to stay free or it will die.

                  1 Reply Last reply
                  1
                  • banditoB Offline
                    banditoB Offline
                    bandito
                    wrote on last edited by bandito
                    #9

                    So I finally figured out to connect to a network drive. If I put /run/user/1000/gvfs/smb-share:server=192.168.0.1,share=volume(sda1) as the path in QDirIterator it works fine. Had to use QFileDialog to fine the path however. Using "//192.168.0.1/volume(sda1)" as a path doesn't work.

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

                      Interesting ! How did exactly did you extract that path ?

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

                      banditoB 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Interesting ! How did exactly did you extract that path ?

                        banditoB Offline
                        banditoB Offline
                        bandito
                        wrote on last edited by
                        #11

                        @SGaist said in Connect to network drive:

                        Interesting ! How did exactly did you extract that path ?

                        Sorry, I didn't use QDialog, I used QFIleDialog. Using QFileDialog I found the share and after selecting I sent the QFile.fileName() to qDebug(). That's how I found it. Weird I know.

                        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