Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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



  • 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.



  • 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.



  • 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 :)



  • 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?



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


Log in to reply