Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Something about module import paths changed in Qt5.9.1? (Uppercase squashed to lowercase?)

Something about module import paths changed in Qt5.9.1? (Uppercase squashed to lowercase?)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 1 Posters 1.1k 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.
  • timdayT Offline
    timdayT Offline
    timday
    wrote on last edited by
    #1

    This is a weird one.

    I have a Qt (QML in a QQuickView host) app with a long history. It's been left to languish on Qt5.7 but recently I've got interested in updating it to a newer version. It works when I build it with Qt versions 5.7, 5.8 & 5.9(.0)... but when I build it vs. anything after that (e.g 5.9.1) I start seeing an issue which suggests something changed about the handling of import paths and their case sensitivity. (I'm building on Linux BTW).

    My app has a directory MyAppContent/ with some javascript and QML files and a qmldir containing

    module MyAppContent
    MyMessages 1.0 MyMessages.js
    

    (and some additional .js lines) which is all baked into the app resources as qrc:///MyAppContent/...

    In the working versions QML files using import MyAppContent 1.0 Just Work. But from 5.9.1 onwards (5.9.2, 5.9.3 and 5.9.4 all tried) I get the curious message qrc://myappcontent/MyMessages.js: file to open is a directory and QML which tries to import MyAppContent fails to load. It's curious because of the way that myappcontent has apparently been squashed from MyAppContent. Certainly my code doesn't contain the string myappcontent anywhere... it's always MyAppContent.

    Browsing around the documentation for QML modules and import I can't find anything which convinces me one way or the other. There's an example at the end of this page which seems to show exactly what I'm doing (it wouldn't be the first time documentation has lagged behind changes to the reality though). And I can't spot anything obviously relevant in the 5.9.1 changelogs. On the other hand the mention of these module identifiers being URIs makes me wonder whether some sort of case-insensitive handling of URIs has crept in to cause trouble.

    Any ideas?

    1 Reply Last reply
    1
    • timdayT Offline
      timdayT Offline
      timday
      wrote on last edited by timday
      #3

      Aha... think I have it figured out...

      To enable the QML engine find the module in the resources, I've always found its been necessary to use one of these lines (some background):

      viewer.engine()->addImportPath("qrc:/");      // Works on Qt 5.9 or earlier.  Works on Qt 5.9.1 or later.
      viewer.engine()->addImportPath("qrc://");     // Works on Qt 5.9 or earlier.  FAILS on Qt 5.9.1 or later.
      viewer.engine()->addImportPath("qrc:///");    // Works on Qt 5.9 or earlier.  Works on Qt 5.9.1 or later.
      

      Guess which form I was using in the app which stopped working between Qt5.7 and 5.9.x?

      To be honest I've never been too clear what the right number of slashes to use in URIs is. But clearly something changed about how two are handled. (And actually now I look at https://en.wikipedia.org/wiki/Uniform_Resource_Identifier it seems only one or three would be comply with the syntax there; whether the initial "extra" two are required apparently depends on the scheme... which begs the question whether qrc URIs should really always be qrc:/// or whether a simple qrc:/ will do?)

      Trivial testcase demonstrating the issue can be found here: https://bitbucket.org/timday/qtissue002 (the Qt version is set in MAKE-linux or MAKE-mac; the addImportPath is in main.cpp).

      Will mark this solved when I've confirmed the fix applies to the main app too...

      1 Reply Last reply
      1
      • timdayT Offline
        timdayT Offline
        timday
        wrote on last edited by
        #2

        Hmmm... I threw together a simplified standalone testcase I thought should demonstrate the problem... and it worked fine with all versions of Qt I tried from 5.7 to 5.9.4. So it's not as simple as module names getting downcased. Investigations continue....

        1 Reply Last reply
        0
        • timdayT Offline
          timdayT Offline
          timday
          wrote on last edited by timday
          #3

          Aha... think I have it figured out...

          To enable the QML engine find the module in the resources, I've always found its been necessary to use one of these lines (some background):

          viewer.engine()->addImportPath("qrc:/");      // Works on Qt 5.9 or earlier.  Works on Qt 5.9.1 or later.
          viewer.engine()->addImportPath("qrc://");     // Works on Qt 5.9 or earlier.  FAILS on Qt 5.9.1 or later.
          viewer.engine()->addImportPath("qrc:///");    // Works on Qt 5.9 or earlier.  Works on Qt 5.9.1 or later.
          

          Guess which form I was using in the app which stopped working between Qt5.7 and 5.9.x?

          To be honest I've never been too clear what the right number of slashes to use in URIs is. But clearly something changed about how two are handled. (And actually now I look at https://en.wikipedia.org/wiki/Uniform_Resource_Identifier it seems only one or three would be comply with the syntax there; whether the initial "extra" two are required apparently depends on the scheme... which begs the question whether qrc URIs should really always be qrc:/// or whether a simple qrc:/ will do?)

          Trivial testcase demonstrating the issue can be found here: https://bitbucket.org/timday/qtissue002 (the Qt version is set in MAKE-linux or MAKE-mac; the addImportPath is in main.cpp).

          Will mark this solved when I've confirmed the fix applies to the main app too...

          1 Reply Last reply
          1

          • Login

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