Important: Please read the Qt Code of Conduct -

How to add private uri to QML Plugin

  • Hi everyone!

    I have a plugin for QML on C++. In this plugin I have a few classes which I want to use as a private in QML but don't want to share it to public users. I don't know any ways to create private QML types so I decide to create a special url. For example my plugins has a uri like:

    and I've use it in QML like:

    import 1.0

    But I want to create another uri for private classes something like this:

    And than use it like:

    import 1.0

    I try do this:

    QString privateUri = QString("%1.private").arg(uri);
    qmlRegisterSingletonType<MySingelton>(privateUri.toStdString().c_str(), 1, 0, "MySingelton", cache_manager_singletontype_provider);

    But when I try to load my test application I received error:

    QQmlApplicationEngine failed to load component
    qrc:/main.qml:5 static plugin for module "" with name "SDKPlugin" cannot be loaded: Cannot install singleton type 'MySingelton' into unregistered namespace ''

    What I do wrong? How I can register a new namespace for my plugin? Is this possible?