Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Can't see types from my QML Designer plugin in 'QML Types' section in designer.

    Tools
    2
    5
    744
    Loading More Posts
    • 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.
    • L
      LScott last edited by LScott

      I've written a QML plugin ('MyLibQML') project to expose components from my custom controls library 'MyLib'. This allows the designer to load and display *.ui.qml forms containing said custom controls. Problem is, whatever I do, I can't get the types to show up in the 'QML Types' section, alongside the existing Qt Quick types.

      My file structure looks like this:

      MyLib ->
      ----designer ->
      --------images ->
      ------------frame-icon.png
      --------MyLibQML.metainfo
      --------RectangleSpecifics.qml
      ----plugin.qmltypes
      ----qmldir
      libMyLibQML.so
      

      My 'plugin.qmltypes' was generated using:

      qmlplugindump -nonrelocatable MyLib 1.0 . > plugin.qmltypes
      

      My 'qmldir' file:

      module MyLib
      typeinfo plugin.qmltypes
      classname MyLibQML
      plugin MyLibQML ../
      designersupported
      

      My 'MyLibQML.metainfo':

      MetaInfo {
          Type {
              name: "MyLib.Rectangle"
              icon: "images/frame-icon.png"
      
              ItemLibraryEntry {
                  name: "MyRectangle"
                  category: "MyLib - Graphics"
                  libraryIcon: "images/frame-icon.png"
                  version: "1.0"
                  requiredImport: "MyLib.Rectangle"
              }
          }
      }
      

      Obviously, my 'libMyLibQML.so' registers a type 'MyRectangle' into the import URI 'MyLib.Rectangle' with a version of '1.0'.
      So my question is... what am I missing here? From all the documentation I've seen, this should work just fine.

      1 Reply Last reply Reply Quote 0
      • T
        Thomas Hartmann last edited by

        For items to show up in the library you have to add the correct import to the current file. Maybe this is the missing piece.

        1 Reply Last reply Reply Quote 1
        • L
          LScott last edited by

          No dice, I added:

          import MyLib.Rectangle 1.0
          

          and still nothing. I can add the type manually to the '*.ui.qml' file, and it does indeed populate correctly in the designer, but the 'Rectangle' type still does not show up in the 'QML Types' dialog.

          Thank you for your response, anyway :)

          1 Reply Last reply Reply Quote 0
          • L
            LScott last edited by

            Figured it out, it seems to be an undocumented limitation that the import URI of a type cannot end in that type...
            For example, registering type 'Rectangle' under the import URI 'MyLib.Rectangle' works as far as QML is concerned, but the designer will not parse it correctly, however the import URI 'MyLib.Graphics' will work just fine...

            So to fix this, I changed the import URI that the plugin registers the 'Rectangle' type under from 'MyLib.Rectangle' to 'MyLib.Graphics', reflected that change in the MyLib.metainfo file, and now it shows up in the 'QML Types' tab.

            From what I can tell, this requirement/limitation is completely undocumented. Not sure if it is a bug in the designer, or a real limitation that isn't documented, but needless to say it was very frustrating to grapple with. Any chance this can be reflected in the documentation in the future?

            1 Reply Last reply Reply Quote 0
            • T
              Thomas Hartmann last edited by

              I created a bug report: https://bugreports.qt.io/browse/QDS-804

              1 Reply Last reply Reply Quote 0
              • First post
                Last post