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. Load from absolute path
Forum Updated to NodeBB v4.3 + New Features

Load from absolute path

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 3 Posters 1.4k Views 2 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.
  • J.HilkJ Online
    J.HilkJ Online
    J.Hilk
    Moderators
    wrote on last edited by J.Hilk
    #1

    Hi,
    I would like to know if anyone has recently ( 5.12 -5.15) tried to load a Qml file from an absolute path, rather than from the resource system.

    It works fine on MacOS.
    But for the life of me, on windows I always get the "QQmlApplicationEngine faild to load component" message

    I would like to know if I'm doing something silly, or if thats actually somehow broken 🤷‍♂️


    I should have added code from the beginning ;)
    gir repo:


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by fcarney
      #2

      The original worked fine on Linux, but not windows. It gave a network error.
      I think the url was being created like "c:" was the scheme.

      engine.load(QUrl::fromLocalFile(QString(QMLSOURCEDIR )+ "/main.qml"));
      

      The error I got was "network error".

      C++ is a perfectly valid school of magic.

      1 Reply Last reply
      2
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        It works here, try putting an example of what you tried.

        I tried with this url : QUrl url(QStringLiteral("file:///D:/coding/untitled30/main.qml"));

        1 Reply Last reply
        2
        • J.HilkJ Online
          J.HilkJ Online
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          Thank @fcarney and @GrecKo for your time in testing this,

          From what I can see now - I 'm at home now and don't have a Windows Pc to check - I was being silly!

          I relied on QUrls auto deduction, of a local file path. That happen to work on unix systems but of course not on windows.

          So changing my code from

          engine.load(QUrl(QString(QMLSOURCEDIR )+ "/main.qml"));
          

          to

          engine.load(QUrl::fromLocalFile(QString(QMLSOURCEDIR )+ "/main.qml"));
          

          like @fcarney suggested, should solve the problem cross platform 👍

          @GrecKo

          It works here, try putting an example of what you tried.

          I appended my opening post with a link to a git hub project, where the "problem" originated from

          This should solve the issue, but I can't test it right now, I'll close the topic as soon as I verified it!

          Thanks!


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply
          0
          • fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #5

            @J-Hilk said in Load from absolute path:

            as I verified it!

            I know you need to verify this yourself, but I did test on both linux and windows 10.

            C++ is a perfectly valid school of magic.

            J.HilkJ 1 Reply Last reply
            1
            • fcarneyF fcarney

              @J-Hilk said in Load from absolute path:

              as I verified it!

              I know you need to verify this yourself, but I did test on both linux and windows 10.

              J.HilkJ Online
              J.HilkJ Online
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @fcarney ok 👌 I couldn‘t quite tell from your post 😬

              I‘ll mark it as the correct one


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0

              • Login

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