Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Can't see types from my QML Designer plugin in 'QML Types' section in designer.
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
5 Posts 2 Posters 1.1k Views
  • 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 Offline
    L Offline
    LScott
    wrote on last edited by LScott
    #1

    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
    0
    • T Offline
      T Offline
      Thomas Hartmann
      wrote on last edited by
      #2

      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
      1
      • L Offline
        L Offline
        LScott
        wrote on last edited by
        #3

        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
        0
        • L Offline
          L Offline
          LScott
          wrote on last edited by
          #4

          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
          0
          • T Offline
            T Offline
            Thomas Hartmann
            wrote on last edited by
            #5

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

            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