I cannot open a file that is online in the application by default. Server with Windows , the machine from which the project is launched, also with Windows .
Example with a local file:
QString filepath = QObject::trUtf8("C://folder\\ГЛАВНАЯ ПАПКА\\ПАПКА_1\\2_Папка\\1.mkv"); QUrl fileurl = QUrl::fromLocalFile(filepath); bool result = QDesktopServices::openUrl(fileurl); if (result == false) { показываю сообщение об ошибке } In this case, the file is opened in the application by default, the result is result = true .
An example of a file on the local network:
QString filepath = QObject::trUtf8("//SOMESERVER\\folder\\ГЛАВНАЯ ПАПКА\\ПАПКА_1\\2_Папка\\1.mkv"); QUrl fileurl = QUrl::fromLocalFile(filepath); bool result = QDesktopServices::openUrl(fileurl); if (result == false) { показываю сообщение об ошибке } File does not open, result = false .
I also tried instead of fromLocalFile use fromUserInput .
fileurl.host() shows instead of SOMESERVER value of someserver . I tried to manually set the value of the host , but the register is not considered. I tried through ip too. But the file still does not open.
He suggested that the problem is due to Cyrillic characters, or spaces in the path, or additional points in the file name, but the path type //SOMESERVER\\folder\\1\\1.mkv has the same effect.
fileurl.errorString() returns "Invalid URL"": empty" .
fileurl.isValid() returns true .
fileurl.isLocalFile() returns true .
fileurl.isEmpty() returns false .
QFile openfile(filepath); openfile.exists() returns true .
\\with/- aleks.andr