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. What is the difference between qrc:/ and qrc:///
Forum Update on Monday, May 27th 2025

What is the difference between qrc:/ and qrc:///

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 416 Views
  • 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.
  • N Offline
    N Offline
    nejatafshar
    wrote on last edited by nejatafshar
    #1

    When loading main qml the root QML file, one can use qrc:/ or qrc:/// as the url scheme:

    engine.load(QUrl(QLatin1String("qrc:/main.qml")));
    

    or

    engine.load(QUrl(QLatin1String("qrc:///main.qml")));
    

    Both approaches work but it seems that qrc:/// is the recommended approach. So what's the difference between the two?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @nejatafshar said in What is the difference between qrc:/ and qrc:///:

      So what's the difference between the two?

      The second one is a valid url while the first is not. The first one only works because the QString passed to the QUrl is parsed in tolerant mode: https://doc.qt.io/qt-5/qurl.html#QUrl-2

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      5
      • N Offline
        N Offline
        nejatafshar
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thanks. The first one is more concise and I regularly use it where ever I want to address a resource item. So which one is recommended? Is there any circumstances that the first one fails?

        ODБOïO 1 Reply Last reply
        0
        • N nejatafshar

          @Christian-Ehrlicher Thanks. The first one is more concise and I regularly use it where ever I want to address a resource item. So which one is recommended? Is there any circumstances that the first one fails?

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @nejatafshar said in What is the difference between qrc:/ and qrc:///:

          So which one is recommended

          the valid one.

          @nejatafshar said in What is the difference between qrc:/ and qrc:///:

          Is there any circumstances that the first one fails?

          yes as @Christian-Ehrlicher said,
          most likely it will fail if QUrl::ParsingMode is set to QUrl::StrictMode

          1 Reply Last reply
          3

          • Login

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