Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDir doesn't accept valid local QUrl
Forum Updated to NodeBB v4.3 + New Features

QDir doesn't accept valid local QUrl

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 305 Views 1 Watching
  • 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 Offline
    A Offline
    Asperamanca
    wrote on last edited by
    #1

    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
    0
    • A Asperamanca

      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 Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

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

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved