Connect to network drive
-
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.
-
You need to mount it with your local OS, no help from Qt here.
-
@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.
-
Hi,
What OS are you using ?
How is your drive seen by this OS ?
How are you trying to access it with Qt ? -
@bandito said in Connect to network drive:
I already have it mounted.
Then you can simply use QFile with the path in the filesystem
-
@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.
- Linux (Ubuntu)
-
@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.
-
@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
-
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.
-
Interesting ! How did exactly did you extract that path ?
-
@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.