Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QDesktopServices can't open network drive path.



  • 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



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


Log in to reply