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

QDir doesn't accept valid local QUrl



  • So apparently the QML FileDialog delivers an URL to the file or folder. In my case, I select a valid local folder (not file), and try to open the folder via QUrl

        // folderUrl originating from QML
        const auto& path = folderUrl.path();
        QDir checkDir(path);
        if ( ! checkDir.exists())
    

    The only strange thins is that 'path' displays a preceding slash ("/C:/someFolder"), otherwise it's perfectly fine and exists. However, QDir cannot open it (exists() returns false)

    Any clues what goes wrong here?



  • @Asperamanca
    Answering my own question: QUrl::toLocalFile is the right one to use in this case, instead of ::path()


Log in to reply