Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to add private uri to QML Plugin
shav last edited by
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 com.company.sdk 1.0
But I want to create another uri for private classes something like this:
And than use it like:
import com.company.sdk.private 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 "com.company.sdk" with name "SDKPlugin" cannot be loaded: Cannot install singleton type 'MySingelton' into unregistered namespace 'com.company.sdk.private'
What I do wrong? How I can register a new namespace for my plugin? Is this possible?
jpnurmi last edited by