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. .qmltypes not found by QtCreator for custom Qml Components
Forum Updated to NodeBB v4.3 + New Features

.qmltypes not found by QtCreator for custom Qml Components

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 1 Posters 1.8k 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.
  • A Offline
    A Offline
    AlexanderF
    wrote on last edited by AlexanderF
    #1

    I'm having trouble getting the qmldir and the qmlplugindump / .qmltypes infrastructure to work in my QtCreator with Qt 5.12.3

    I have a folder QmlResources that builds a library of the same name (CMake based).
    Inside it there is a /qml folder containing a CustomButton.qml and a qmldir. Both are added to a qml.qrc located in the main folder. There is also a /src folder containing a class based on QQmlExtensionPlugin, so the result is

    /QmlResources
            CMakeLists.txt
            qml.qrc
        /qml/
            CustomButton.qml
            qmldir
        /src/
            QmlResources.h
    

    The qml.qrc looks like this

    <RCC>
        <qresource prefix="/QmlResources">
            <file>qml/CustomButton.qml</file>
            <file>qml/qmldir</file>
        </qresource>
    </RCC>
    

    qmldir:

    module QmlResources
    CustomButton 0.1 CustomButton.qml
    plugin QmlResources
    

    CustomButton.qml

    import QtQuick 2.6
    import QtQuick.Controls 1.4
    Button {
        // some button stuff
    }
    

    QmlResources.h

    class CustomQmlResources final: public QQmlExtensionPlugin {
        Q_OBJECT
        Q_PLUGIN_METADATA(IID "somestring")
    
    public:
        CustomQmlResources ();
        void registerTypes(const char * uri) override {
            qmlRegisterType(QUrl("qrc:/QmlResources/qml/CustomButton.qml"), uri, MAJOR, MINOR, "CustomButton");
        };
    };
    

    Now QtCreator is telling me when I import QmlResources 0.1 in a QML file:
    "QML module does not contain information about components contained in plugins"
    e44ebc18-c08b-4c0e-82ea-ca0ab42cb279-grafik.png

    When I try to run "qmlplugindump.exe QmlResources 0.1" in the qml folder I get

    QQmlComponent: Component is not ready
    file:///typelist.qml:3:1: module "QmlResources" is not installed
    

    I've read all of the documentation about qmldirs and plugins multiple times and I can't figure out how this is supposed to work

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AlexanderF
      wrote on last edited by AlexanderF
      #2

      I made some progress and I was able to generate a .qmltypes file.
      Some issues I had to fix:

      • qml.qrc needed to be in the same folder as the qmls and qmldir so the path doesn't need /qml/
      • The registerType has to use the now shorter url, eg qmlRegisterType(QUrl("qrc:/QmlResources/CustomButton.qml"), uri, MAJOR, MINOR, "CustomButton");
      • With the cxx plugin it seems to be unnecessary adding the CustomButton to the qmldir. What needs to be there is "module QmlResources" and "plugin QmlResources"
      • The qmlplugindump.exe needs to be run inside the release folder with the release.dlls, otherwise it won't find required dependencies, eg "/loaddependencies.qml:2:1: module "QtQuick" plugin "qtquick2plugin" not found"

      After generating the .qmltypes file I added it to the /qml/ folder and put this in the qmldir "typeinfo qmlresources.qmltypes". Unfortunately it's still trying to auto generate and failing due to the QtQuick dependency it fails to find.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        AlexanderF
        wrote on last edited by
        #3

        I got it to work! What was missing was installing the .qmltypes file into the build folder of QmlResources together with the qmldir, so both can be found by the QtCreator

        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