Your user must:
- Implement a QObject in C++ that provides the required functionality.
- Subclass
QQmlExtensionPlugin
to register that QObject as a QML type.
- Build a DLL (or SO or DYLIB) for #1 and #2, and write a
qmldir
file to tell the QML engine how to load the DLL.
EDIT: Qt Creator automates a bit of this process for you. Go to "File" -> "New File or Project..." -> "Projects" -> "Libraries" -> "Qt Quick 2 Extension Plugin"
You can find more details about this process in the documentation:
Note 1: Your user won't be writing a *.qml file.
Note 2: Each plugin must be in its own subfolder. This is because each C++ plugin needs one qmldir
file, but you can't have multiple qmldir
files in the same folder.
You can find some real examples in your Qt installation. Go to, say, C:\Qt\5.3\mingw482_32\qml -- all the subfolders here contain QML plugins, mostly written in C++. Here is some sample source code: