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. Windows - qt_add_qml_module failed to load the plugin
Forum Updated to NodeBB v4.3 + New Features

Windows - qt_add_qml_module failed to load the plugin

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 3 Posters 769 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by
    #1

    Hi All

    Unable to load the plugin created using qt_add_qml_module
    CMake on Windows , Qt 6.6.3, Mingw_64.
    Creating the library & adding new qml module using
    qt_add_qml_module(..)

    This creates the plugin.

    However when I import in QML, it is unable to load the plugin.
    I tried to load the plugin using QPluginLoader. This also fails.

    Same CMake configuration works on Linux without any change.

    Anyone facing similar issue ?

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

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

      Here is the answer - qt_add_qml_module builds plugin & one shared library. Both have to be in path. I tried to add the path using the addLibraryPath. Adding the path using addLibraryPath did not help. Finally I modified the path environment variable. It started working.

      1. May be bug with addLibraryPath. Need to file a bug on this.
      2. add the path of the shared library & plugin to environment variable. It works.

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

      JKSHJ 1 Reply Last reply
      0
      • dheerendraD dheerendra has marked this topic as solved on
      • dheerendraD dheerendra referenced this topic on
      • dheerendraD dheerendra

        Here is the answer - qt_add_qml_module builds plugin & one shared library. Both have to be in path. I tried to add the path using the addLibraryPath. Adding the path using addLibraryPath did not help. Finally I modified the path environment variable. It started working.

        1. May be bug with addLibraryPath. Need to file a bug on this.
        2. add the path of the shared library & plugin to environment variable. It works.
        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        @dheerendra Thanks for sharing your solution! There is no bug, however.

        qt_add_qml_module() generates 2 library targets by default: One "backing target" like MyModule.dll (which contains your actual QML code) and one "plugin target" like MyModuleplugin.dll (which contains plugin interface)

        • Your backing target must be put in one of Windows' standard DLL search paths (see https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-unpackaged-apps ) -- usually, you would put it next to your *.exe (or you could also put it in one of your PATH folders).

        • Your plugin target must be put in a "module folder". This "module folder"...

          • ...must have the same name as your QML module
          • ...must contain your plugin target AND the module definition files (qmldir file + *.qmltypes file)
          • ...must be found inside of your QML engine's import paths. See https://doc.qt.io/qt-6/qqmlengine.html#importPathList

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

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

          @JKSH True. Agree with you. Expectation was that after adding the library path it should work. This is where my confusion.

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

          Q 1 Reply Last reply
          0
          • dheerendraD dheerendra

            @JKSH True. Agree with you. Expectation was that after adding the library path it should work. This is where my confusion.

            Q Offline
            Q Offline
            QtTester
            wrote on last edited by
            #5

            @dheerendra can you show some demo source? I don't konw how to write qml plugin and use the component in app.qml, thank you .

            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