Results 1 to 5 of 5

Thread: Connect to network drive

  1. #1
    Join Date
    Mar 2016
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default 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.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Connect to network drive

    If the drive is not mounted at the OS level (ie. using linux mount or making a connection as a Windows network drive) so the OS filesystem sees it then Qt can't see it either, since Qt's file services are layered on top of the underlying file system.

    You can possibly use QProcess to mount the drive, at which point you can access it, as explained in this stackoverflow post based on linux. I imagine there is some equivalent in Windows.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Mar 2016
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Re: Connect to network drive

    Quote Originally Posted by d_stranz View Post
    If the drive is not mounted at the OS level (ie. using linux mount or making a connection as a Windows network drive) so the OS filesystem sees it then Qt can't see it either, since Qt's file services are layered on top of the underlying file system.

    You can possibly use QProcess to mount the drive, at which point you can access it, as explained in this stackoverflow post based on linux. I imagine there is some equivalent in Windows.
    I am actually using Linux, Ubuntu specifically and I have the drive mounted already.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,229
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Connect to network drive

    I am actually using Linux, Ubuntu specifically and I have the drive mounted already.
    Does the account from which you are running the Qt app have the same access rights as the directory at the mount point? If so, I am surprised that the Qt program can't see it. Perhaps one of the linux gurus here can add more.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Mar 2016
    Posts
    18
    Thanks
    2
    Thanked 1 Time in 1 Post
    Qt products
    Qt5

    Default Re: Connect to network drive

    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.
    Last edited by bandito; 10th April 2020 at 18:04.

  6. The following user says thank you to bandito for this useful post:

    d_stranz (10th April 2020)

Similar Threads

  1. Programmatically writting to a network drive.
    By ayanda83 in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2017, 11:49
  2. Connect Sqlite database from Android device through the network
    By Laureta in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 12th February 2015, 08:25
  3. Qt Designer Working from network drive
    By list@ceepro.dk in forum Qt Tools
    Replies: 1
    Last Post: 9th April 2010, 20:26
  4. Replies: 0
    Last Post: 6th February 2009, 00:41
  5. No network when Modem Emulator connect to a real device
    By tommy_tang in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 10th December 2007, 09:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.