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. Changing the content of qmldir at runtime

Changing the content of qmldir at runtime

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 1.6k 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.
  • T Offline
    T Offline
    Tân Ngọc Đỗ
    wrote on last edited by
    #1

    Hi Guys,

    I have a problem with qmldir in qrc. I Created a resource file(qrc) for my project; in this file I add all the qml files and qmldir into it. My problem is : I have to specify the absolute paths to the location of Qml plugin I wrote in qmldir . If It's on my computer; it's easy. But if It's on another computer, I need to modify the paths of qmldir. Is there any ways to change the content of qmldir file when It's embedded into resource file ?

    Thank you!

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Not sure why you need absolute path. Did you try something like this ?

      import QtQuick 2.2;
      import 'qrc:/pthinks/qmlmodules/';
      import 'qrc:/pthinks/maths/factorial.js' as fact;

      Here qmldir is under qmlmodules path.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tân Ngọc Đỗ
        wrote on last edited by
        #3

        Because I embedded all qml files into qrc; so, if I want QML files in qrc import my plugins I also need to add qmldir into qrc. The problem is : qmldir in qrc can not understand the relative path, it only know the absolute path to my plugin . I also use QQmlEngine::addPluginPath() to add the location of plugin for engine . But the engine can not recognize plugins so I need to add absolute paths to qmldir

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          qmldir can contain the relative path from the directory where this qml files exist.

          <TypeName> <Version> <File>

          Here is file can be relative path from the directory where qmldir exist.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • T Offline
            T Offline
            Tân Ngọc Đỗ
            wrote on last edited by
            #5

            Hello,

            If I don't add qmldir into qrc; the relative path is ok. For ex: ../Plugin.
            But if I add qmlfir into qrc, QmlEngine can't understand the current path to specify the location of Plugin, so I need to use the absolute path: /home/myname/plugin .

            Do you have other solution ?

            Thanks

            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