Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved QDir doesn't accept valid local QUrl

    General and Desktop
    1
    2
    81
    Loading More Posts
    • 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.
    • A
      Asperamanca last edited by

      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?

      A 1 Reply Last reply Reply Quote 0
      • A
        Asperamanca @Asperamanca last edited by

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

        1 Reply Last reply Reply Quote 2
        • First post
          Last post