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. QDesktopServices can't open network drive path.
Forum Updated to NodeBB v4.3 + New Features

QDesktopServices can't open network drive path.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 441 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.
  • B Offline
    B Offline
    bronstein87
    wrote on last edited by bronstein87
    #1

    Trying to open network drive path using QDesktopServices:

            QString filePath = "//Camera20/data/";
            QUrl url;
            if (filePath.startsWith("\\\\") || filePath.startsWith("//"))
            {
                url.setUrl(QDir::toNativeSeparators(filePath));
            }
    
            else
            {
                url = QUrl::fromLocalFile(filePath);
            }
            QDesktopServices::openUrl(url);
    

    But it returns an error: ShellExecute '%5C%5CCamera20%5Cdata%5C' failed (error 2).
    What is wrong in my code?
    win7, qt 5.9.4

    JonBJ 1 Reply Last reply
    0
    • B bronstein87

      Trying to open network drive path using QDesktopServices:

              QString filePath = "//Camera20/data/";
              QUrl url;
              if (filePath.startsWith("\\\\") || filePath.startsWith("//"))
              {
                  url.setUrl(QDir::toNativeSeparators(filePath));
              }
      
              else
              {
                  url = QUrl::fromLocalFile(filePath);
              }
              QDesktopServices::openUrl(url);
      

      But it returns an error: ShellExecute '%5C%5CCamera20%5Cdata%5C' failed (error 2).
      What is wrong in my code?
      win7, qt 5.9.4

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @bronstein87
      I'm either right or wrong on this, but is your network path as a url supposed to start with file:?

      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