QDesktopServices::openUrl() fails in Qt 6.8 on macOS for file paths with special characters ([, ])
-
I’ve encountered a regression in behavior when upgrading from Qt 5.15 to Qt 6.8 on macOS related to QDesktopServices::openUrl().
Working code in Qt 5.15:
QString x = "/Volumes/Untitled 99/testfolder1/test copy'[.txt"; QFileInfo fi(x); qDebug() << "Exists:" << fi.exists() << ", isFile:" << fi.isFile(); QUrl url = QUrl::fromLocalFile(x); bool ret = QDesktopServices::openUrl(url); qDebug() << "RET:" << ret;
Output on Qt 5.15 (macOS):
Exists: true , isFile: true
RET: trueSame code fails in Qt 6.8:
- list itemQFileInfo confirms the file exists
- QUrl::fromLocalFile() generates a valid URL
- But QDesktopServices::openUrl() returns false (Character [ appear to break the behavior)
There is any workaround?
-
I’ve encountered a regression in behavior when upgrading from Qt 5.15 to Qt 6.8 on macOS related to QDesktopServices::openUrl().
Working code in Qt 5.15:
QString x = "/Volumes/Untitled 99/testfolder1/test copy'[.txt"; QFileInfo fi(x); qDebug() << "Exists:" << fi.exists() << ", isFile:" << fi.isFile(); QUrl url = QUrl::fromLocalFile(x); bool ret = QDesktopServices::openUrl(url); qDebug() << "RET:" << ret;
Output on Qt 5.15 (macOS):
Exists: true , isFile: true
RET: trueSame code fails in Qt 6.8:
- list itemQFileInfo confirms the file exists
- QUrl::fromLocalFile() generates a valid URL
- But QDesktopServices::openUrl() returns false (Character [ appear to break the behavior)
There is any workaround?
@PuskasAlex said in QDesktopServices::openUrl() fails in Qt 6.8 on macOS for file paths with special characters ([, ]):
There is any workaround?
Except creating a bug report (search before if there is already one) - compare the code between Qt5 and Qt6 - maybe you can spot the problem.